Out of memory

when i deploy my application i get OutOfMemory error. I tested the application through JProbe and found that there are lots of SringBuffers etc. are still there on the heap. How to get rid of the unwanted objects.using System.gc will help?
[267 byte] By [v_vishala] at [2007-10-2 23:34:30]
# 1
If you are retaining unnecessary references to objects, they cannot be garbage-collected. De-referencing objects when you're finished with them may help. A manual request for gc will not usually do anything.
ChuckBinga at 2007-7-14 16:16:25 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

If by "de-referencing objects" you mean assigning null to the references, then if that helps you have found the places where you are retaining unnecessary references to objects. Setting references to null in unreferenced objects shouldn't help the garbage collector, as it already knows that the object containing the references is unreferenced so it won't follow the interior references when looking for live objects. Conversely, setting references to null for references that you are still using can lead to NullPointerExceptions later on, when they are hard to debug.

Peter.Kessler@Sun.COMa at 2007-7-14 16:16:25 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
try to study the "finalize" keyword it should help you.
czetsuyaa at 2007-7-14 16:16:25 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4

when i am running the application using -verbose:gc, i see that GC is working fine but though i keep the application idle for some time still the memory usage as seen in 'Task manager' continuously going up. I think this is causing the OOM.

is there any way we can find which threads are still running in the backgound?

v_vishala at 2007-7-14 16:16:25 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5

To see the stack trace of all java threads, you can send SIGQUIT signal (Ctrl+\ on Solaris and Ctrl+Break on Windows) to your running application. And to get the stack trace of native threads also, you need to use native debugging tools e.g. pstack on unix systems and windbg on windows platform.

poonambajaja at 2007-7-14 16:16:25 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 6
Increase the Heap size (-ms an d- mx) and check.
vishal_usaa at 2007-7-14 16:16:25 > top of Java-index,Java HotSpot Virtual Machine,Specifications...