IntelliJ Java IDE
The moose likes Performance and the fly likes dispose() does not release objects Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply Bookmark "dispose() does not release objects" Watch "dispose() does not release objects" New topic
Author

dispose() does not release objects

Venkatesh Rajendran
Ranch Hand

Joined: May 17, 2001
Posts: 59
Hi All,
I have one swing application which has some screen whenever I click close or cancel the screens i am dispossing the object.
In this situation if i look on the task manager CPU memory size is getting increase whenever open new screen but it does not get decreased when i close a screen.
This cause if i opened 20 screens 30 MB of memory in use but currently i am using only one screen hence my system gets slow.
If any one know alternative way to release the object after saying dispose().
Thanks in advance
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1109

Hi Venkatesh,
The mechanism by which the java virtual machine (JVM) releases memory, is know as "garbage collection".
According to the Java Virtual Machine Specification, a JVM does not need to implement garbage collection.
Since I saw no mention -- in your post -- of which JVM you are using, I cannot say whether it implements garbage collection or not.
I know that SUN's JVM (version 1.3.1) _does_ implement garbage collection. However, as far as I know, you have no control over when garbage collection will occur. I'm quite sure it will not occur immediately after you "dispose" of your "screen". For SUN's JVM, the "java" command has the "verbose:gc" option:
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/java.html
[I am assuming you are on Windows -- since I didn't see any mention of your platform in your post.]
There are many articles available on the Internet regarding the garbage collection mechanism of the JVM. You may find some relevant articles at these Web sites (assuming you haven't already found them):
http://www.javaworld.com
http://developer.java.sun.com
http://www-106.ibm.com/developerworks/java/
Hope this has helped you.
Good Luck,
Avi.
Venkatesh Rajendran
Ranch Hand

Joined: May 17, 2001
Posts: 59
Hi Avi,
Thanks for your useful information and reply. I am having J2SDK 1.4.1 and Windows 2000.
I will have look in to the links provided by you.
Thanks & Regards,
Venkat
 
 
subject: dispose() does not release objects
 
Threads others viewed
JFrames
Dynamic Swing
JInternalFrame is closed, but stay in the memory
Most efficient way to use a spritesheet?
Flow Design concern
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com