How does malloc tell the kernel to allocate more memory?
I'm trying to write a tracer on memory allocation, and I'm having a little trouble figuring this out.
At some point, malloc has to call the kernel to tell it to allocate more memory for this user process, right? I can't figure out which function malloc calls, or where in the code (line number) it's called.
I'm looking at glib-2.3.1 to try and find my answers. After all, that's where malloc is defined, right?
TIA.
Joseph Wagner
Quoted 2 lines · Joseph D. Wagner
I'm trying to write a tracer on memory allocation, and I'm having a little trouble figuring this out.
You sure this has not been done before?
Quoted 4 lines
At some point, malloc has to call the kernel to tell it to allocate more memory for this user process, right? I can't figure out which function malloc calls, or where in the code (line number) it's called.
I dont know much about memory management, but there is some documentation at lkdp.tk ..you might want to check it out, although AFAIK it's not finished yet..
Signature · 8 lines
With best regards, Boris B. - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 4 lines · Boris Bezlaj
Quoted 2 lines · Joseph D. Wagner
I'm trying to write a tracer on memory allocation, and I'm having a little trouble figuring this out.
Quoted 9 lines
You sure this has not been done before?
Quoted 4 lines
At some point, malloc has to call the kernel to tell it to allocate more memory for this user process, right? I can't figure out which function malloc calls, or where in the code (line number) it's called.
I dont know much about memory management, but there is some documentation at lkdp.tk ..you might want to check it out, although AFAIK it's not finished yet..
man {sbrk|brk}?
--ibz
Quoted 6 lines · Joseph D. Wagner
I'm trying to write a tracer on memory allocation, and I'm having a little trouble figuring this out.
At some point, malloc has to call the kernel to tell it to allocate more memory for this user process, right? I can't figure out which function malloc calls, or where in the code (line number) it's called.
malloc can use either sbrk/brk or (anonymous) mmap to obtain more memory from the kernel.
Quoted 2 lines
I'm looking at glib-2.3.1 to try and find my answers. After all, that's where malloc is defined, right?
It's in glibc (GNU libc), not glib (the GNOME utility library).
Signature · 6 lines
Glynn Clements <[email protected]> - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs
RE: How does malloc tell the kernel to allocate more memory? -- CORRECTION
Quoted 4 lines
Quoted 2 lines
I'm looking at glib-2.3.1 to try and find my answers. After all, that's where malloc is defined, right?
It's in glibc (GNU libc), not glib (the GNOME utility library).
Sorry, I meant to say glibc. I double checked. I am using glibc-2.3.1.
Joseph Wagner
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 10 lines · Joseph D. Wagner
I'm trying to write a tracer on memory allocation, and I'm having a little trouble figuring this out.
At some point, malloc has to call the kernel to tell it to allocate more memory for this user process, right? I can't figure out which function malloc calls, or where in the code (line number) it's called.
I'm looking at glib-2.3.1 to try and find my answers. After all, that's where malloc is defined, right?
Quoted 11 lines
TIA.
Joseph Wagner
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
I don't have the answer. But look at something that already does this. electric-fence detects illegal memory access (great for debugging)
ccmalloc is also a memory debugging library. It detects memory leaks and stuff like that.
Maybe after you checked this out you can rather work on improving these library's or extending them to do exactly what you want rather than reinventing the weel :-)
Good luck
-Heinrich
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs