GAllocator vs. g_free (was: GMemChunk for skip lists)



[My question:]
> > 	Also, what is the point of a GAllocator?
[Tim's response:]
[...]
> excessive temporary use of a certain structure type.
> know you better free them later on again, you need to use allocators.
[...]
> if you have a certain portion of code that uses *lots* of GLists or
> GNodes, and you know you'd better want to release all of them after
> a short while, you'd want to use a GAllocator.

	I have recently learned that free() (or g_free() ) does not return
the freed memory to the operating system until after the program is
killed.  So if I g_malloc() a ton of memory, and then g_free() it, my
program is still using a crapload of RAM until it is killed.

	Is it any different with a GAllocator?  I.e., if I need to
temporarily allocate a ton of GNodes, and hence push my own GAllocator,
after I pop that GAllocator will the O.S. get the memory back for other
apps/disk caching/etc.?  Or is that memory *still* eaten up until after my
program is killed?

	Also, the same question for a GMemChunk.  If I call
g_mem_chunk_alloc() followed by either g_mem_chunk_free() (or
g_blow_chunks() ), is the memory still used up until my app dies?  Or does
it somehow, magically, go immediately back to the O.S.?


Thank You,
Derek Simkowiak
dereks@kd-dev.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]