[Issue 19947] OutOfMemoryError with GC-allocs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 21 09:00:10 UTC 2019


--- Comment #7 from Rainer Schuetze <r.sagitario at gmx.de> ---
> How does this square with the fact that calling GC.collect()
> inside the for loop also makes the program run to completion?

When running GC.collect() after the allocation, you are changing the amount of
memory that the GC overallocates before running the next collection (2 times
the live memory at the time of the previous collection). This changes the
probability of getting false pointers.

> Also, the array is initialized with 0, so any false false pointers
> would be invisible to the user code.

The content of the int[] array is not scanned, the false pointers in the data
segment (and the stack, -gx might help) are the issue here. These can pin the
large allocations. Address randomization (ASLR) makes it rather unpredictable,


More information about the Digitalmars-d-bugs mailing list