Bug 20438 – [Reg 2.086] GC: memory not reusable when calling GC.collect after GC.free
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-12-07T19:58:50Z
Last change time
2019-12-08T10:13:36Z
Keywords
pull
Assigned to
No Owner
Creator
Rainer Schuetze
Comments
Comment #0 by r.sagitario — 2019-12-07T19:58:50Z
Reported in the learn forum: This program shows increasing memory usage even though allocated memory is freed manually:
version=FREE;
version=COLLECT;
import std.stdio;
import core.memory;
immutable int[] intZ = [1,2,3,4,4,6,6,8,8,65,8,23];
void main() {
writeln(GC.stats);
enum max = 100000;
foreach (i; 0 .. max) {
bool doprint = !(i % (max/10));
int[] z = intZ.dup;
if (doprint) writef("%7d ", GC.stats.usedSize);
version(FREE) GC.free(cast(void*) z.ptr);
version(COLLECT) GC.collect();
if (doprint) writefln("%7d", GC.stats.usedSize);
}
}
This doesn't happen when either version FREE or COLLECT is not defined.
@rainers created dlang/druntime pull request #2858 "fix issue 20438 - [Reg 2.086] GC: memory not reusable when calling GC…" fixing this issue:
- fix issue 20438 - [Reg 2.086] GC: memory not reusable when calling GC.collect after GC.free
fix detection of page with unused allocation slots
https://github.com/dlang/druntime/pull/2858
Comment #3 by dlang-bot — 2019-12-08T10:13:36Z
dlang/druntime pull request #2858 "fix issue 20438 - [Reg 2.086] GC: memory not reusable when calling GC…" was merged into stable:
- 7afdd5712c9299ef274ec148f83a4c98a5cc75c3 by Rainer Schuetze:
fix issue 20438 - [Reg 2.086] GC: memory not reusable when calling GC.collect after GC.free
fix detection of page with unused allocation slots
https://github.com/dlang/druntime/pull/2858