Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

this.dispose() and freeing memmory extremely urgent please help

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
I'm confused with memmory issues. I have created internal frame which inturn
has objects within it. These objects have large data structures within them
and take up much memmory.
When I run the program after the operations and clicking on all the buttons
a new tab opens and I destroy the internal frame immediately and call
System.gc() straight away. I thought that this would free all respective
resources if the garbage collector is called. I then go to do a similar
operations and the computer is temperamental sometimes it runs out of
memmory and sometimes it doesn't.

What I've found happens is that if I close the internal frame by clicking on
the little x on the top right hand corner is that I can run as many
operations as I like. If I call dispose from within the object it is
tempermental.

What is the difference between clicking on the x button on the top right
hand corner of the internal frame and calling dispose on the object. I
thought that System.gc() would free my memmory but it doesn't. I have a
feeling it doesn't invoke the garbage collector straight away. NB I am
putting this to extremes by trying to do operations very quickly. But I
would like to understand the nature of the problem so I need help quickly.


Thanks alot

Chris
 
The System.gc() does not directly call the Garbage Collector. It just tells the JVM that you have set a bunch of your reference variables to null. Yes, that is the trick, set all your reference variables to null when you are done with them. The Garbage Collector is a Damean thread which runs when ever it gets a chance and it will free up those reference variables if they are set to null.

I am not sure what your code looks like like, but try using the null on references you done using. Clean up before you call dispose() to close your Frame.

Good luck,
Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top