Re: Declaring outside a loop: speed? memory?




Steve W. Jackson wrote:
Declaring the variable "mine" before the loop makes its scope wider than
just the loop. As a result, the last instance after the loop terminates
is still in existence until the wider scope is finished. Only then is
it certain to be eligible for garbage collection, should the JVM need to
do so. So if there's a good deal that follows this loop, there could be
a benefit to the first approach.

Actually, I think the compiler/JVM is smart enough to make references
elegible for GC if the ref isn't used for the rest of the scope.

.



Relevant Pages

  • Re: extract string from file
    ... >> The common suggestion which is equivalent to the loop around fgetc() ideas ... "constructive" as it relates to the phrase "constructive criticism" ... than the existence of hardware that became obsolete long before the ...
    (comp.lang.c)
  • Re: extract string from file
    ... >> The common suggestion which is equivalent to the loop around fgetc() ideas ... "constructive" as it relates to the phrase "constructive criticism" ... than the existence of hardware that became obsolete long before the ...
    (alt.comp.lang.learn.c-cpp)
  • Re: PL/I, COBOL, Advantages, Equivalence, et al
    ... loop variable *after* the loop terminates. ... That requires two explicit instructions plus an explicit declaration, ... The lower range is, of course, constitutes an explicit initialization. ...
    (comp.lang.pl1)
  • Re: Response to Karen and to Willem on recursive proofs
    ... )|> All you need to do is prove that 'preposition-in-loop' holds during the ... provably infinite loop can be proven correct by this ... Technically, this method proves that *if* a loop terminates, it terminates ... You all think I'm paranoid, ...
    (comp.programming)
  • Re: Scanning for last modified date
    ... the only thing to do is to insert an IF-Construct into your loop ... through the subdirectories, so you can control the existence of 'notes.ini'. ...
    (microsoft.public.scripting.wsh)