Re: general performance question




"Knute Johnson" <nospam@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:47a1c80f$0$31474$b9f67a60@xxxxxxxxxxxxxxxxxxxxx
Lasse Reichstein Nielsen wrote:
Knute Johnson <nospam@xxxxxxxxxxxxxxxxxxxxxxx> writes:

Mike Schilling wrote:
...
if (condition)
{
LargeObject lg = new LargeObject();
lg.doStuff()
// See discussion below
}

I don't think that is true. If you create an Object in a loop and
then reassign another Object to the same reference in the loop, the
first Object is eligible for garbage collection (and will be).

The previous poster didn't mention loops, merely a nested block
scope.
For a loop, the value set in the last iteration also leaks the
block.

/L

How can it if the reference is created in the block?

The method's stack frame isn't collected until the method exits; it has no
notion of block scope.


.



Relevant Pages

  • Re: general performance question
    ... first Object is eligible for garbage collection. ... For a loop, the value set in the last iteration also leaks the ... How can it if the reference is created in the block? ... The method's stack frame isn't collected until the method exits; it has no notion of block scope. ...
    (comp.lang.java.programmer)
  • Re: general performance question
    ... first Object is eligible for garbage collection. ... For a loop, the value set in the last iteration also leaks the ... How can it if the reference is created in the block? ... no notion of block scope. ...
    (comp.lang.java.programmer)
  • Re: general performance question
    ... then reassign another Object to the same reference in the loop, ... notion of block scope. ... As soon as that occurs oy's first Object can be GC'd even before the end of method, ...
    (comp.lang.java.programmer)
  • Re: StackOverflow Exception in JNI
    ... > I have a loop written in C/JNI which calls back a Java object (which ... temporary objects in your native method and then return a valid ... reference without thinking too much about these issues. ...
    (comp.lang.java.programmer)
  • Re: Looping-related Memory Leak
    ... memory leak / balloon for reasons I cannot figure out. ... end of the loop. ... reference count never reaches zero, and they remain alive until the ... the generational collector doesn't break cycles that involve ...
    (comp.lang.python)