[Issue 13801] New: Garbage collector fails to work after lots of small allocations

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Nov 30 13:42:17 PST 2014


https://issues.dlang.org/show_bug.cgi?id=13801

          Issue ID: 13801
           Summary: Garbage collector fails to work after lots of small
                    allocations
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: critical
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: dlang at chillichef.com

The program below uses around 3.5GB of RAM on my machine.

 - Commenting out the "arr" allocation reduces it to 860KB.
 - Commenting out the list appending reduces it to 8.8MB.

This is seriously affecting me as my program is now allocating over 10GB before
OOM'ing.

Things to note:
 - Reduce the size multiplier to only 1000 and the amount of memory being used
drops to hardly anything.
 - Increase the multiplier to 3000 and the amount of memory being used
drastically increases.


-------------------------------------------

import core.memory : GC;

import std.range : iota;

const ulong size = chunkSize * 2000;
const ulong chunkSize = 4 * 1024 * 1024;

immutable struct S {
  string a;
  ulong b;
}

void main() {
  S[] list;

  foreach(i; iota(0, size, chunkSize)) {
    list ~= S("", i);
  }

  while(true) {
    ubyte[] arr = new ubyte[chunkSize];
    //GC.collect();
    //GC.minimize();
  }
}

--


More information about the Digitalmars-d-bugs mailing list