Results 1 to 2 of 2
Thread: Memory Free issue
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Dec 2012
Memory Free issue
Currently facing issue with memory free . Can anyone suggest me how memory free works inside the kernel. Specifically - when continuos alloc and free are used what exactly happens . I see memory freed by process is not acquired by Kernel. The output of "top" command shows continuous increment of usage of memory by a process.
- Join Date
- Dec 2011
- Turtle Island West
Well, I'm no kernel expert, but it would seem logical that if a program is alloc'ing and free'ing a lot of memory continuously, that the kernel would be efficient and just leave the memory availaible to that app instead of reclaiming it, and of course just have to make it available again shortly down the road. Constructive laziness, if you will.
I would also guess that the behavior would change depending on how much total memory is available and how it's being fought over by the various programs running. There must be some test programs out there that push the kernel's memory management techniques to their limits.
Someone else must know a lot more than me about the deep wizardry of the kernel's innards in this regard.
I, for one, use glib, g_malloc() and g_free() when I can, and they may very well have different dynamics than malloc() and free(). glib also has some wonderful wrapper functions like g_strdup_printf() that take care of a lot the dirty work for you.
And I do recall some heavy debate about this very issue some years ago on a usenet site, probably around the 2.0 kernel's birthday.
BTW, I don't think you should post twice to different forums. Once is good enough. I believe it's known as crossposting, and frowned upon.