Re: Garbage collection problem
From: Lee Fesperman (firstsql_at_ix.netcom.com)
Date: 03/02/04
- Next message: David Cano: "Re: Problem with getting width/height of image"
- Previous message: gajo: "Re: Applet won't work on the internet, yet it works on my hard drive!"
- In reply to: John C. Bollinger: "Re: Garbage collection problem"
- Next in thread: John C. Bollinger: "Re: Garbage collection problem"
- Reply: John C. Bollinger: "Re: Garbage collection problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 02 Mar 2004 21:51:43 GMT
John C. Bollinger wrote:
>
> There are some subtleties involved in determining eligibility for GC in
> Java, the most notable being "hidden" local variables. Hidden local
> variable arise because Java does not actually have nested local variable
> scopes at the VM level -- only at the Java source level. To the VM all
> local variables are treated equally. Therefore, a local reference
> variable that goes out of scope in the Java sense sticks around until
> the method in which it is declared terminates, no matter how long that
> may be. Any object it refers to remains strongly reachable until that time.
That is no quite true. At the bytecode level, local variables are 'slots' in the stack
frame. Some compilers will reuse the slots allocated to nested local variables thus
removing the reachability of references in the reused slots.
This only applies to direct interpretation of bytecodes. Runtime compilers are free to
apply additional optimizations, including reuse of 'unnested' local variables. I have
seem JVMs that perform even more esoteric optimizations.
> That there are other GC models where the answer might be a bit
> different, perhaps including some in which the problem is not a trick
> question. For Java, however, the bottom line answer is "there is no
> such reason."
For Java, it is best to assume that (as you said) a local variable remains reachable
until the method terminates. However, it is not guaranteed.
-- Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com) ============================================================== * The Ultimate DBMS is here! * FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
- Next message: David Cano: "Re: Problem with getting width/height of image"
- Previous message: gajo: "Re: Applet won't work on the internet, yet it works on my hard drive!"
- In reply to: John C. Bollinger: "Re: Garbage collection problem"
- Next in thread: John C. Bollinger: "Re: Garbage collection problem"
- Reply: John C. Bollinger: "Re: Garbage collection problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|