garbage collection w/ threads
Hi,
I'm having problem trying to reclaim memory allocated by my server threads. My threads are shut down gracefully by returning from the run method. The problem i'm observing is that it always takes about 5min before the allocated memory is reclaimed.Is there a default time interval in which garbage collection start? if so what is the exact value and how do i change it? I've tried invoking garbage collection by placing 'System.gc()' at the end of the run() method, but it doesn't look like JVM recycle the threads. Any ideas or suggestions will be greatly appreciated. Thank you in advance.
-Jeff
[633 byte] By [
jln7] at [2007-9-26 4:55:28]

Hi,
Thank you for the quick response. My app is a simple multi-threaded server. All it does is it spawns off a server thread whenever a client comes in. It accepts the connection, then sleep for a few seconds, then closes the socket. So i launch serveral clients and watch how many threads I can create. I always notice the server threads are not recycled right away. All the server threads should be shut down after a few seconds they are created. I hope that helped.
jln7 at 2007-6-29 18:49:15 >

There are no guarantees about when the garbage collector runs. It tends to run only when memory within a given heap space is exhausted. You can get quicker dispose times by using the -Xincgc option, but along with the lack of any easily detectable GC pause you get slower heap performance (about 10% according to Sun). Even with that, if the eden or survior space doesn't GC, and the object doesn't migrate into the tenured space (I'm talking about the 1.3.x and later server JVM), then it won't be collected any sooner anyway.
Chuck