On Thu, 09 Mar 2000 13:07:18 PST, Derek Simkowiak said:
> 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.
This depends on whether your malloc package is smart enough to call sbrk()
to release totally unused pages, and whether your operating system
understands how to do it.
QUick summary: sbrk() is the system call to get/free heap memory pages
from the operating system. malloc() then keeps track of what's allocated
in that heap.
IN any case, free() is usually pretty cheap, and a good idea. Consider the
effect on swap space of these two code segments:
for(i=0;i<100000;i++) {int *foo= malloc(1000); free(foo) };
for(i=0;i<100000;i++) {int *foo = malloc(1000); }
Think about that. It's called "a memory leak". ;)
--
Valdis Kletnieks
Operating Systems Analyst
Virginia Tech
--
To unsubscribe: mail -s unsubscribe [EMAIL PROTECTED] < /dev/null
- [gtk-list] Re: Another (stupid) GAllocator question Havoc Pennington
- [gtk-list] Re: GMemChunk for skip lists Tim Janik
- [gtk-list] Whence GdkWChar Derek Simkowiak
- [gtk-list] Re: Whence GdkWChar Owen Taylor
- [gtk-list] GAllocator vs. g_free (was: GMemChunk for sk... Derek Simkowiak
- [gtk-list] Re: GAllocator vs. g_free (was: GMemChunk fo... Havoc Pennington
- [gtk-list] g_memmove() (another RAM quickie) Derek Simkowiak
- [gtk-list] Re: g_memmove() (another RAM quickie) Tim Janik
- [gtk-list] Re: g_memmove() (another RAM quickie) Erik Mouw
- [gtk-list] Re: GAllocator vs. g_free (was: GMemChunk fo... Tim Janik
- [gtk-list] Re: GAllocator vs. g_free (was: GMemChunk fo... Valdis . Kletnieks
- [gtk-list] Re: GAllocator vs. g_free (was: GMemChunk fo... Derek Simkowiak
- [gtk-list] Gapped Text Buffer Derek Simkowiak
- [gtk-list] right click menu david rohde
- [gtk-list] Re: right click menu Matthew Cordes
- [gtk-list] Re: right click menu Emmanuel DELOGET
