Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Don't finalize dtor-less objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
Safety0ff committed Jul 12, 2014
1 parent 9ff77d4 commit 380781c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rt/lifetime.d
Expand Up @@ -73,10 +73,11 @@ extern (C) Object _d_newclass(const ClassInfo ci)
else
{
// TODO: should this be + 1 to avoid having pointers to the next block?
BlkAttr attr = BlkAttr.FINALIZE;
BlkAttr attr = BlkAttr.NONE;
// extern(C++) classes don't have a classinfo pointer in their vtable so the GC can't finalize them
if (ci.m_flags & TypeInfo_Class.ClassFlags.isCPPclass)
attr &= ~BlkAttr.FINALIZE;
if (ci.m_flags & TypeInfo_Class.ClassFlags.hasDtor
&& !(ci.m_flags & TypeInfo_Class.ClassFlags.isCPPclass))
attr |= BlkAttr.FINALIZE;
if (ci.m_flags & TypeInfo_Class.ClassFlags.noPointers)
attr |= BlkAttr.NO_SCAN;
p = GC.malloc(ci.init.length, attr, ci);
Expand Down

1 comment on commit 380781c

@Kozzi11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this cause memory leak regression https://issues.dlang.org/show_bug.cgi?id=14573

Please sign in to comment.