GC pathological case behaviour
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 28 12:03:14 PDT 2016
On my machine (OS X), this program eats up memory with no end in
sight
import std.concurrency;
import core.stdc.stdio;
void start()
{
while(true)
{
receive(
(int msg)
{
char[2] s = '\0';
s[0] = cast(char)msg;
puts(s.ptr); // remove this => no memory leak
}
);
}
}
void main()
{
auto hw_tid = spawn(&start);
while(true)
{
send(hw_tid, 64);
auto b = new ubyte[](1_000); // 10_000 => no memory leak
}
}
This is very odd, no? I'm not sure if it's a bug, but it sure is
surprising. Why should "puts" cause a GC leak (writeln is the
same)? What's so special about small allocations that allows all
my memory to get filled up?
More information about the Digitalmars-d
mailing list