Will final referenced objects be garbage collected just like other objects?

Hi all,

I have just finished spoting some memory leaks in my system; in which it seems that the objects pointed by final references seems not garbage collected (or not as efficiently as other objects).

So may I ask

1. Will the final references themself be recycled when getting out of the effective range (say the final local variable declared in a function after function finished) ? If not this means we will always have some reference to the objected referred and they will never get recycled, right ?

2. When an object is refered by a final reference, is there any difference in the behavior of collection?

Thanks in advance. I have tried looking up in JVM spec but cannot find it...

[725 byte] By [Suo_alexa] at [2007-10-3 4:45:15]
# 1

A final field, parameter or local variable is simply something that can only be set once. There is nothing else special about them (ignoring some memory model issues for final fields).

If the variable itself is not reachable then the object is not reachable through that variable. Note however that the reachability of a local variable might be different at runtime to what you would think from your source code.

Some code fragments might help in identifying your problem.

davidholmesa at 2007-7-14 22:49:32 > top of Java-index,Java HotSpot Virtual Machine,Specifications...