Re: Fragmenting memory



Ray Mond a écrit :
Is it possible to have a fragmented region of memory if no memory leaks are
occuring?  If so, how can this happen?  Thanks.

Memory allocations and desallocations don't happen synchronously. This simple sample creates a little fragmentation:


(assuming that the memory is linearly allocated).
alloc(a)
alloc(b)
alloc(c)
descalloc(b)

now the memory between a and b is free, this is a fragmentation.

desalloc(a) and desalloc(c) happen later in the process execution.

There would not be fragmentation is allocation/desallocation were using the same model as LIFO stacks (the last block allocated is the first block freed).

Florent
.