From: Jonathan A. <jon...@gm...> - 2007-06-26 12:39:54
|
Hi. I have been using JUnit for a project using Hibernate and Spring from Eclipse. Hibernate and Spring is pretty memory demanding things and I have repeatadly hit the OutOfMemoryException and increased the memory parameters to the JVM. Now however I am afraid I have reached the limit of my memory because suddenly I get more or less a frozen computer and it seems to just be swapping. This happens before the JUnit plugin for Eclipse has reported even one test. Thus it would seem to me as if JUnit first setups for all tests (grabbing all menory available) and then performs the tests. Is this the case? Wouldn't it be better to take one test at a time and clear memory usage in between? No matter if this is the case do anyone have an idea of a solution to my problem which isn't of the type "buy more memory" (Because I think that would just push my problem forward a bit...) // Jonathan Alvarsson |
From: David S. <sa...@mi...> - 2007-07-03 17:54:58
|
(I accidentally dropped the thread from the list. CC'ing the list to get them up to date.) My best guess is that the "fork" being discussed is the option on the junit task in ant. What are you allocating memory-wise for each test? Thanks, David On 7/3/07, Jonathan Alvarsson <jon...@gm...> wrote: > On 6/28/07, David Saff <sa...@mi...> wrote: > > Jonathan, > > > > Are you using JUnit 3? If so, a move to JUnit 4 should help a lot. > > It will require a small amount of rewrite of the test code, but the > > memory usage profile should be much more reasonable. Thanks, > > Okey so I changed some code into JUnit 4 compatible. But this didn't > change much. It's still the same. When I run all tests in my package > the test run turns really slow after just about half of the tests but > those tests run at normal speed if runned separately... > > Someone said somthing about fork. Do you know anything about that? > > // Jonathan > |
From: Jonathan A. <jon...@gm...> - 2007-07-03 18:41:11
|
It is the Spring application context. I solved it now by using just one static reference to one aplication context instead so now I guess I have quite some time until I will run out of memery next time... The principal problem still exists for JUnit though... On 7/3/07, David Saff <sa...@mi...> wrote: > > (I accidentally dropped the thread from the list. CC'ing the list to > get them up to date.) > > My best guess is that the "fork" being discussed is the option on the > junit task in ant. > > What are you allocating memory-wise for each test? Thanks, > > David > > On 7/3/07, Jonathan Alvarsson <jon...@gm...> wrote: > > On 6/28/07, David Saff <sa...@mi...> wrote: > > > Jonathan, > > > > > > Are you using JUnit 3? If so, a move to JUnit 4 should help a lot. > > > It will require a small amount of rewrite of the test code, but the > > > memory usage profile should be much more reasonable. Thanks, > > > > Okey so I changed some code into JUnit 4 compatible. But this didn't > > change much. It's still the same. When I run all tests in my package > > the test run turns really slow after just about half of the tests but > > those tests run at normal speed if runned separately... > > > > Someone said somthing about fork. Do you know anything about that? > > > > // Jonathan > > > -- // Jonathan |
From: David S. <sa...@mi...> - 2007-07-03 18:57:02
|
Jonathan, I have not used Spring directly, so learning a bit more will probably help me in the future. Are you directly shutting down the application contexts, or should that happen automatically at garbage collection? If you create a lot of application contexts in a loop, do you see similar results to what you saw for JUnit? JUnit 3 did indeed create all of the instance fields for all test objects at once, but this is intentionally fixed in JUnit 4. Can you give me an example of how your tests look that would help me figure out whether JUnit can do something more to help your situation? David On 7/3/07, Jonathan Alvarsson <jon...@gm...> wrote: > It is the Spring application context. I solved it now by using just one > static reference to one aplication context instead so now I guess I have > quite some time until I will run out of memery next time... > > The principal problem still exists for JUnit though... > > > On 7/3/07, David Saff <sa...@mi...> wrote: > > (I accidentally dropped the thread from the list. CC'ing the list to > > get them up to date.) > > > > My best guess is that the "fork" being discussed is the option on the > > junit task in ant. > > > > What are you allocating memory-wise for each test? Thanks, > > > > David > > > > On 7/3/07, Jonathan Alvarsson <jon...@gm...> wrote: > > > On 6/28/07, David Saff <sa...@mi... > wrote: > > > > Jonathan, > > > > > > > > Are you using JUnit 3? If so, a move to JUnit 4 should help a lot. > > > > It will require a small amount of rewrite of the test code, but the > > > > memory usage profile should be much more reasonable. Thanks, > > > > > > Okey so I changed some code into JUnit 4 compatible. But this didn't > > > change much. It's still the same. When I run all tests in my package > > > the test run turns really slow after just about half of the tests but > > > those tests run at normal speed if runned separately... > > > > > > Someone said somthing about fork. Do you know anything about that? > > > > > > // Jonathan > > > > > > > > > -- > // Jonathan |
From: Jonathan A. <jon...@gm...> - 2007-07-03 19:18:29
|
On 7/3/07, David Saff <sa...@mi...> wrote: > Jonathan, > > I have not used Spring directly, so learning a bit more will probably > help me in the future. Are you directly shutting down the application > contexts, or should that happen automatically at garbage collection? > If you create a lot of application contexts in a loop, do you see > similar results to what you saw for JUnit? You really only use one. It's the big container keeping all the objects. I have looked around a bit more and discovered that Spring actually have alot of classes made especially for JUnit 3 that helps with these kind of things. > JUnit 3 did indeed create all of the instance fields for all test > objects at once, but this is intentionally fixed in JUnit 4. Can you > give me an example of how your tests look that would help me figure > out whether JUnit can do something more to help your situation? What I meant in claiming that the problem is not really solved was based on this text: <http://www.symphonious.net/2006/09/19/junit-memory-usage-in-eclipse/> > David |