[Issue 1804] Severe GC leaks with repetitive array allocations
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 14 20:07:47 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=1804
safety0ff.bugz <safety0ff.bugz at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
CC| |safety0ff.bugz at gmail.com
Resolution| |FIXED
--- Comment #9 from safety0ff.bugz <safety0ff.bugz at gmail.com> 2014-02-14 20:07:41 PST ---
(In reply to comment #8)
> I'm reopening this, because I noticed the problem
> (core.exception.OutOfMemoryError after about 20000 iterations) still exists on
> Windows XP 32bit with latest dmd 2.063. Works ok on Linux though.
The original bug was fixed. Your observation is due to false pointers, consider
the code at the end of this comment:
When version = A is enabled, the false pointers cause memory to be considered
alive much longer, exactly like the code in the OP.
When version = A is disabled, only pointers to the start of the memory block
make the GC consider it "alive," so less memory is retained by false pointers.
-------------- Begin Code ----------------------
import std.stdio;
import core.memory;
version = A;
void main()
{
for(uint i=1; i!=0; i++)
{
version(A) auto tmp = cast(char*)GC.malloc(i * 1024, GC.BlkAttr.NO_SCAN);
else auto tmp = cast(char*)GC.malloc(i * 1024, GC.BlkAttr.NO_SCAN |
GC.BlkAttr.NO_INTERIOR);
for (uint j = 0; j<i*1024; j+=1024)
tmp[j] = 0; // poke the memory
if(i % 1_000 == 0)
writefln("%d iterations, roughly %.1f MiB", i, i/1024.0);
}
}
-------------- End Code -------------------------
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list