Good to the last drop.
Steven Schveighoffer
schveiguy at gmail.com
Thu Mar 31 22:57:58 UTC 2022
On 3/31/22 3:44 PM, WhatMeWorry wrote:
> I run the program (at the bottom) and get, as expected, the run-time out
> of memory error:
>
> PS C:\D\sandbox> .\Reserve.exe
> newCapacity = [ 1]
> newCapacity = [ 3]
> newCapacity = [ 5]
> o o o
> newCapacity = [ 905,207,293]
> newCapacity = [ 905,207,805]
> newCapacity = [ 905,208,317]
>
> core.exception.OutOfMemoryError at src\core\lifetime.d(126): Memory
> allocation failed
>
>
> Is there a way to programmatically determine the exact maximum memory
> size available to the DRuntime’s array implementation?
Note that your code example is not hitting the limit of the largest
contiguous block that could be allocated, but the sum of it and *all the
smaller blocks*, as those are still used by the GC.
At any of those extensions, it might reallocate a new block, and copy
the data there. In that case, the original block is abandoned (and might
be freed to the GC), but it's not used in any subsequent allocations,
because your new allocations won't fit! So the GC's usage of memory
might be much higher than you think.
What I'd do is a binary search via *new processes* to see where it breaks.
-Steve
More information about the Digitalmars-d-learn
mailing list