[DGD] Pathological memory allocation?

Dread Quixadhal quixadhal at gmail.com
Wed Oct 24 01:03:11 CEST 2018


I assume that when you do x = x + ({ 1 }), the engine will look for a memory block that’s the size of x + 1 elements, and if it doesn’t find one, it will allocate a new one and mark the old one as available.

So, if you do a loop where you keep adding elements one-at-a-time, you’ll end up using a very large amount of system memory, as there will be lots of N-1 sized chunks sitting around available, but unused.

Sent from Mail for Windows 10

From: Raymond Jennings
Sent: Tuesday, October 23, 2018 3:06 PM
To: All about Dworkin's Game Driver
Subject: Re: [DGD] Pathological memory allocation?

Does that still apply even if there is an upper bound on the lengths
of said arrays and strings?

The arrays never grow beyond 80 elements and string sizes are capped
at around 4k

Would even that normally cause a full 8 gigabytes of dynamic memory to
be allocated with only 100 megabytes in use?

Honestly with figures like that I'm tempted to send you a core dump
with a binary.

On Tue, Oct 23, 2018 at 1:23 PM Felix A. Croes <felix at dworkin.nl> wrote:
>
> Raymond Jennings <shentino at gmail.com> wrote:
>
> > I'm running an unusual setup, with loads of string and array
> > operations and dmemsize is reaching up into a full G with only about
> > 40 M actually in use.
> >
> > Even more interesting, is that dmemsize keeps climbing by the megabyte
> > yet actual usage stays fairly low.
>
> You are probably continuously growing arrays and/or strings by appending
> to them.  Every time it grows bigger, it has to be reallocated and all
> available chunks are too small, thus a lot of memory is wasted.
>
> If so, this is highly inefficient, not just wasteful of memory.  Rewrite
> your code.
>
> Regards,
> Felix Croes
> ____________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd
____________________________________________
https://mail.dworkin.nl/mailman/listinfo/dgd




More information about the DGD mailing list