A memory leak
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   lucky_lucky
Posted On:   Tuesday, August 19, 2003 07:01 AM

I'm à 4 years experience java developper and i've never found why when i use swing the memory grow up even you release frame. I've read than it is not allowed to use anomymous listener because we can't remove them. I've track program with optimizeit Ok, i've try just un simple program : a Jframe with 2 buttons One to open a new JFrame One to close the JFrame and of course i used named ActionListener Even this simple example consume memory. I'm really desepointed because i've started with java in 1996 It's a mistery for me. If somebody could help me because i love Java technologies but if i can not resolve this problem i will oth   More>>

I'm à 4 years experience java developper and i've never found why when i use swing the memory grow up even you release frame.

I've read than it is not allowed to use anomymous listener because we can't remove them.

I've track program with optimizeit

Ok, i've try just un simple program : a Jframe with 2 buttons

One to open a new JFrame
One to close the JFrame

and of course i used named ActionListener

Even this simple example consume memory.

I'm really desepointed because i've started with java in 1996

It's a mistery for me.


If somebody could help me because i love Java technologies but
if i can not resolve this problem i will other technologies because it's not possible for industrial process with not a human behind the computer to restart every day the program

PS: If you look at the memory when you use IDE is the same problem even with the demos of the J2SDK

thanks and excuse me for my bad english

Luciano BROUSSAL

   <<Less

Re: A memory leak

Posted By:   Sascha_Bader  
Posted On:   Wednesday, August 20, 2003 02:12 AM

Hello Luciano,

maybe you simply forgot to call "dispose()" on the Frame ?
Also one must know that the Java Garbage Collector has some guidelines for his actions. Sometimes it could take a long time for a small object to dumped from the heap.
It might also help to call the System.gc() after disposal of larger amounts of objects.
You can give hints to the GC if you explicitly set Object References to null (e.g. myObj = null; ). Also make sure that there are no cross references of objects. Especially action listeners and similar stuff are often forgotten by the programmer when "disposing" GUI elements.

Greetings,
Sascha

Re: A memory leak

Posted By:   Adrian_K  
Posted On:   Tuesday, August 19, 2003 07:38 AM

Its known that swing apps tends to consume some power...but, i.e. I use to use Forte that is a Swing based application with several frames, buttons, windows without restarting the machine for a week or more...And I don't heavy machine!....

There are other possible solutions in order to make a gui for java apps:


SWF: http://www.eclipse.org
Thinlet: http://www.thinlet.com


I you do a google search you will find several alternatives for gui development in java...
About | Sitemap | Contact