Quote:
Originally Posted by Skyld
In your example why would you want it cleared from memory? It seems like you are trying to return a reference to be used elsewhere.
I'm guessing this is expected behaviour; TStaticVars will probably be allocated on the heap and not the stack, and sending a reference to it by return is probably instructing the garbage collector to preserve it in memory because it's expected lifetime is no longer clear (i.e. now the object is expected to outlive the function execution). In scenarios like this, you are normally expected to destroy an object yourself when you are finished with it since it is difficult for the garbage collector to determine whether you still want it or not.
|
Quote:
Originally Posted by Stefan
The TStaticVar will be destroyed once no one else is referencing the object anymore. A reference in a temp.var is still a reference. It's automatically detecting 'circle references'.
|
Hmm, I think I see what you are saying. I'll have to destroy it elsewhere. But what about the issue with joining classes? Is there any way this could be addressed?