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

Commit

Permalink
Merge pull request #1918 from Calrama/fixmemleak
Browse files Browse the repository at this point in the history
Fix leaking memory in shared druntime
  • Loading branch information
MartinNowak authored Sep 23, 2017
2 parents 95fd6e1 + c04a506 commit 4ee4569
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/rt/sections_elf_shared.d
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ extern(C) void _d_dso_registry(CompilerDSOData* data)
}

unsetDSOForHandle(pdso, pdso._handle);
pdso._handle = null;
}
else
{
Expand All @@ -466,7 +465,16 @@ extern(C) void _d_dso_registry(CompilerDSOData* data)

freeDSO(pdso);

if (_loadedDSOs.empty) finiLocks(); // last DSO
// last DSO being unloaded => shutdown registry
if (_loadedDSOs.empty)
{
version (Shared)
{
assert(_handleToDSO.empty);
_handleToDSO.reset();
}
finiLocks();
}
}
}

Expand Down Expand Up @@ -599,7 +607,12 @@ version (Shared) void runFinalizers(DSO* pdso)
void freeDSO(DSO* pdso) nothrow @nogc
{
pdso._gcRanges.reset();
version (Shared) pdso._codeSegments.reset();
version (Shared)
{
pdso._codeSegments.reset();
pdso._deps.reset();
pdso._handle = null;
}
.free(pdso);
}

Expand Down

0 comments on commit 4ee4569

Please sign in to comment.