* How does malloc tell the kernel to allocate more memory?
@ 2002-12-08 18:46 Joseph D. Wagner
2002-12-08 19:29 ` Boris Bezlaj
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Joseph D. Wagner @ 2002-12-08 18:46 UTC (permalink / raw)
To: Linux C Programming, Linux Newbie
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
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: How does malloc tell the kernel to allocate more memory?
2002-12-08 18:46 How does malloc tell the kernel to allocate more memory? Joseph D. Wagner
@ 2002-12-08 19:29 ` Boris Bezlaj
2002-12-08 19:42 ` Ibraheem Umaru-Mohammed
2002-12-08 21:20 ` Glynn Clements
2002-12-09 6:55 ` How does malloc tell the kernel to allocate more memory? Heinrich du Toit
2 siblings, 1 reply; 6+ messages in thread
From: Boris Bezlaj @ 2002-12-08 19:29 UTC (permalink / raw)
To: Joseph D. Wagner; +Cc: Linux C Programming, Linux Newbie
On Sun, Dec 08, 2002 at 12:46:57PM -0600, Joseph D. Wagner wrote:
> 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?
>
> 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..
--
With best regards,
Boris B.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How does malloc tell the kernel to allocate more memory?
2002-12-08 19:29 ` Boris Bezlaj
@ 2002-12-08 19:42 ` Ibraheem Umaru-Mohammed
0 siblings, 0 replies; 6+ messages in thread
From: Ibraheem Umaru-Mohammed @ 2002-12-08 19:42 UTC (permalink / raw)
To: Linux C Programming
* Boris Bezlaj <boris@bandit.kista.gajba.net> [2002-12-08 19:33]:
> On Sun, Dec 08, 2002 at 12:46:57PM -0600, Joseph D. Wagner wrote:
> > 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?
> >
> > 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
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How does malloc tell the kernel to allocate more memory?
2002-12-08 18:46 How does malloc tell the kernel to allocate more memory? Joseph D. Wagner
2002-12-08 19:29 ` Boris Bezlaj
@ 2002-12-08 21:20 ` Glynn Clements
2002-12-09 0:34 ` How does malloc tell the kernel to allocate more memory? -- CORRECTION Joseph D. Wagner
2002-12-09 6:55 ` How does malloc tell the kernel to allocate more memory? Heinrich du Toit
2 siblings, 1 reply; 6+ messages in thread
From: Glynn Clements @ 2002-12-08 21:20 UTC (permalink / raw)
To: Joseph D. Wagner; +Cc: Linux C Programming, Linux Newbie
Joseph D. Wagner wrote:
> 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.
> 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).
--
Glynn Clements <glynn.clements@virgin.net>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How does malloc tell the kernel to allocate more memory?
2002-12-08 18:46 How does malloc tell the kernel to allocate more memory? Joseph D. Wagner
2002-12-08 19:29 ` Boris Bezlaj
2002-12-08 21:20 ` Glynn Clements
@ 2002-12-09 6:55 ` Heinrich du Toit
2 siblings, 0 replies; 6+ messages in thread
From: Heinrich du Toit @ 2002-12-09 6:55 UTC (permalink / raw)
To: Joseph D. Wagner; +Cc: Linux C Programming, Linux Newbie
Joseph D. Wagner wrote:
>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
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-12-09 6:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-08 18:46 How does malloc tell the kernel to allocate more memory? Joseph D. Wagner
2002-12-08 19:29 ` Boris Bezlaj
2002-12-08 19:42 ` Ibraheem Umaru-Mohammed
2002-12-08 21:20 ` Glynn Clements
2002-12-09 0:34 ` How does malloc tell the kernel to allocate more memory? -- CORRECTION Joseph D. Wagner
2002-12-09 6:55 ` How does malloc tell the kernel to allocate more memory? Heinrich du Toit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).