Bug 19455 – GC wastes too much memory

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-11-30T19:47:31Z
Last change time
2018-12-27T08:39:18Z
Keywords
pull
Assigned to
No Owner
Creator
Rainer Schuetze

Comments

Comment #0 by r.sagitario — 2018-11-30T19:47:31Z
The GC allocates in chunks that are a power of 2. This causes a lot of memory wasted: module waste; import core.memory; struct S { char[129] data; } void main() { GC.disable(); 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.
Comment #1 by r.sagitario — 2018-11-30T20:17:03Z
Comment #2 by github-bugzilla — 2018-12-27T08:39:17Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/202ed7031108474185e5dd18170597ea1187cb1c fix issue 19455 - GC wastes too much memory add bins with about 3/2 of existing sizes https://github.com/dlang/druntime/commit/a9954f93cc788a10b1fffc7cb7d468c6ce46772b Merge pull request #2384 from rainers/gc_other_binsizes fix issue 19455 - GC wastes too much memory merged-on-behalf-of: Rainer Schuetze <[email protected]>