Bug 6818 – Globally shared class instances are never released
Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-10-16T15:24:00Z
Last change time
2012-01-29T20:37:19Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2011-10-16T15:24:07Z
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 by andrej.mitrovich — 2012-01-29T20:37:19Z
__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.