www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19455] New: GC wastes too much memory


          Issue ID: 19455
           Summary: GC wastes too much memory
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: r.sagitario gmx.de

The GC allocates in chunks that are a power of 2. This causes a lot of memory

module waste;
import core.memory;

struct S
        char[129] data;

void main()
        foreach (_; 0 .. 1000000)
                new S;

compile and run with

waste.exe --DRT-gcopt=profile:1
Number of collections: 2 Total GC prep time: 0 milliseconds Total mark time: 0 milliseconds Total sweep time: 8 milliseconds Total page recovery time: 3 milliseconds Max Pause Time: 0 milliseconds Grand total GC time: 12 milliseconds GC summary: 247 MB, 2 GC 12 ms, Pauses 0 ms < 0 ms => even though only 129 MB are allocated, the GC needs 247 MB. With a struct size of 128, it needs 145 MB. --
Nov 30 2018