D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6818 - Globally shared class instances are never released
Summary: Globally shared class instances are never released
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-16 15:24 UTC by Andrej Mitrovic
Modified: 2012-01-29 20:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2011-10-16 15:24:07 UTC
import std.stdio;
__gshared Foo foo;
class Foo
{
    ~this() { writeln("Release Foo"); }
}
void main() { foo = new Foo; }

OTOH the dtor gets properly called if it's a thread-local instance.
Is this a known bug?
Comment 1 Andrej Mitrovic 2012-01-29 20:37:19 UTC
__gshared variables go into the data segment (.BSS), and according to the docs:
"Objects referenced from the data segment never get collected by the gc." (http://dlang.org/class.html).

TLS class objects go to the .tls section and get collected.