> if that list is empty, it allocates a new block of memory for it... I
> was always told that doing so was also faster than allocating a new
> chunk of memory for the structure, and I'm not sure if that's true or

The idea is to limit fragmentation.

Malloc and free never return memory to the operating system anyway, so
keeping it allocated isn't really a waste or anything.  But malloc is
written to be fast and general-purpose.  It isn't very well tuned for
applications that run for long periods of time or allocate blocks of
memory in a wide range of sizes.

If you let malloc have its way, over time you would end up with small
bits of allocated memory all over the place with no large, contiguous
areas.  Then when you needed a large chunk of memory, it'd have to go
back to the operating system for more.

So the point of memory pooling is to reserve large blocks of memory so
malloc can't chop them up for other things, otherwise you could wind
up using even more physical memory.
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom

Reply via email to