:: Re: [DNG] Memory management strateg…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Didier Kryn
Fecha:  
A: dng
Asunto: Re: [DNG] Memory management strategies.
Le 31/01/2016 14:28, Edward Bartolo a écrit :
> The question is how do memory managers succeed to remain efficient and
> yet cope with memory allocation of so many different sizes?


     I doubt they're efficient.


     If you really need an efficient memory allocator - but do you 
really need? - then better write one fitted to your needs. A universal 
memory allocator cannot be efficient for all cases. On the other hand, 
if you can organize your application in such a way that you need to 
allocate and deallocate variables according to a simple scheme, then you 
can do it with perfect efficiency. Two examples below that I have 
experimented for my own use:


     If all your objects have the same size, you can organize your 
buffer as an array. Two different sizes, two arrays. If you can manage 
to always allocate and deallocate in oposite order, then you can 
organize your buffer like a stack - you can deallocate objects in the 
middle of the stack, but the memory isn't reclaimed untill all objects 
on top have been freed.


     If you really want to make an efficient use of memory, this is my 
recommendations: organize the behaviour of the program in such a way 
that you can write a perfect allocator-deallocator.


     Didier