On Monday, October 15, 2012 00:51:34 Andrej Mitrovic wrote:
> On 10/15/12, Jonathan M Davis <jmdavisp...@gmx.com> wrote:
> > Anything and everything with no references to it any
> > longer should be up for collection.
> 
> I think this is fuzzy territory and it's a good opportunity to
> properly document GC behavior.

I don't see how it could be fuzzy at all. It makes no sense whatsoever to keep 
_any_ data around once it has nothing referencing it. The constness of an 
object should have _zero_ affect on its scope or lifetime. immutable _does_ 
implicitly make a variable shared, but that has nothing to do with the 
object's lifetime. That just makes it so that it can be used across threads. 
Once no more threads reference it, it should collected. Keeping the data 
around would simply result in the effective equivalent of leaked memory.

> For example, TDPL states that immutable data is always available, and
> that a user should treat such data as if it existed throughout the
> lifetime of the program.

I'd have to see exactly what TDPL says to comment on that accurately, but if 
it means that all immutable data is expected to be around for the entire 
lifetime of the program, then that's a huge problem. If it's something that 
was specifically allocated in ROM when the program started, then that makes 
sense (e.g. string literals on Linux), but nothing allocated on the normal GC 
heap should be kept alive simply because it's immutable. References to it must 
exist.

- Jonathan M Davis

Reply via email to