Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Off Topic: Java developers please read

Author: James Swafford

Date: 09:16:46 11/10/05

Go up one level in this thread


On November 10, 2005 at 08:34:21, James Swafford wrote:

>On November 10, 2005 at 02:07:00, Alessandro Damiani wrote:
>
>>On November 09, 2005 at 18:06:42, James Swafford wrote:
>>
>>>Please forgive me for the off-topic post.
>>>
>>>I have a rather annoying problem that I'm hoping one of you Java
>>>guys can help me with.
>>>
>>>I have a Java/SWING application that works really well, but it consumes
>>>SO much memory.  Actually, it's a client/server program.  The server
>>>side runs off almost no memory, but the client side is a beast.  It's
>>>the SWING libraries.
>>>
>>>Now, I know that Java, and SWING in particular, have reputations for
>>>being memory hogs.  BUT- I'm observing some behavior in my application
>>>that has me troubled.  It never seems to release memory!  That is, the
>>>memory consumption goes steadily up the longer the application is
>>>run.  It's as if the garbage collector is never doing any collection.
>>>
>>>In my research I learned that there are no guarantees about when
>>>the garbage collector will reclaim memory from dereferenced objects.
>>>It may, in theory anyway, delay the process until the system's
>>>resources are below some threshold, then reclaim memory.  That being
>>>the case, it's understandable that the application would have the
>>>appearance of consuming more and more memory with time, IF the
>>>system indeed still had plenty of free RAM.
>>>
>>>However- I'm noticing that it's not reclaiming memory *even when the
>>>system is almost out of free memory*.  As a result, users are complaining
>>>about slow performance when the program has been running for over
>>>an hour or so.
>>>
>>>For a language that is supposed to take the burden of memory management
>>>out of the hands of the developer, I'm sure spending a lot of time
>>>researching and trying to figure out why I'm running out of system
>>>resources.
>>>
>>>I wonder if any of you Java developers might have some insight?
>>>BTW, if it makes any difference at all: my application uses
>>>JInternalFrames, all contained within a single JFrame.  When an
>>>internal frame is closed, I simply do a dispose().  As far as I
>>>know, that should make all the objects within that frame eligible
>>>for garbage collection since they can't be referenced.
>>>
>>>Any ideas or insight would be very much appreciated.
>>>
>>>--
>>>James
>>
>>The main reason of memory leaks in Java are listeners. If an object is not used
>>through direct referencing but you have listeners on it then the garbage
>>collector can only collect the whole set of coupled objects. For instance, if
>>your application class references an object that never dies and this one listens
>>to an object, then this one can never be collected. There are tools around that
>>display currently existing objects in memory, or write your own one through Java
>>Reflections as we did at work.
>
>Thanks, but we don't make extensive use of listeners.
>I do appreciate the tip though..

Ok, we don't make extensive use of WindowLIsteners or Frame Listeners,
though we do have a few.  But... I guess your comment would include
ActionListeners?  Most of my ActionListeners are inlined (anonymous).

Would they not be killed when the internal frame containing the component
they are listening to is disposed of?

--
James



>
>
>>
>>Alessandro



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.