Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

References remain on Thread stack


  • From: robert.hagmann at crossworlds.com (Robert Hagmann)
  • Subject: References remain on Thread stack
  • Date: Sat Nov 12 19:29:24 2005

This behavior is sometimes seen in garbage collected systems.  I am fairly
sure it is allowed behavior of the JVM, but certainly is not the expected
behavior  -- the JVM doesn't ever have to collect anything to be a valid
JVM.  During GC, most JVMs know and use the size of the active stack so the
problem you see does not arise.

You can always null the local variables in doSomeWork() prior to returning
or raising an exception.  That only fixes the code you control.

-- Bob


> -----Original Message-----
> From:	David Soroko [SMTP:davids@xxxxxxxxxxxxxxxx]
> Sent:	Tuesday, August 31, 1999 11:51 AM
> To:	advanced-java
> Subject:	References remain on Thread stack
> 
> References remain on Thread stack
> 
> Suppose I have daemon Runnable whose run() looks like this:
> 
> 
> public void run()
> {
> 	while( !_stop )
>       {
>           waitForSomeConditionToBecomeTrue();
>           doSomeWork();
>       }
> }
> 
> Now, in the doSomeWork() method local variables are created. The behavior
> that I see is that between iterations of the while loop, these variables
> are
> never GCed. The profiler I am using (OptimizeIt) indicates that these
> local variables remain on the thread's stack. This is a concern to me
> since these variables potentially occupy a lot of memory and there can be
> long intervals of time between the while() iterations.
> 
> Is there a way to purge the thread's stack of references? Is this the
> officially correct behavior of the GC?
> 
> 
> 
> 
> 
> 
> 
> 
> --
> 
> ============================================
> David Soroko
> mailto://davids@xxxxxxxxxxxxxxxx
> http://www.geocities.com/SiliconValley/Campus/1628/
> Group Manager, Core Technologies
> Manna Inc.
> ============================================
>