Memory allocation failed. Why?

Stefan Koch via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 20 23:27:01 PST 2016


On Monday, 21 November 2016 at 06:45:04 UTC, ag0aep6g wrote:
> On 11/21/2016 07:36 AM, Stefan Koch wrote:
>> On Monday, 21 November 2016 at 03:58:00 UTC, MGW wrote:
>>> On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote:
>>>> On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote:
>>>>> [...]
> [...]
>> You are appending 100_000_000 Times.
>> Note that this will take up much more then 100 MB.
>> Because the allocator cannot always grow the array.
>> All previously allocated blocks are still in scope and could 
>> be reached.
>> Therefore the memory is not released.
>
> How could they be reached? The only reference is `buf', and 
> when appending triggers relocation, `buf` should point to the 
> new location, no?

Someone could still be hanging on to an old Reference of buf.



More information about the Digitalmars-d-learn mailing list