Memory Management -- The Howto (Beginner)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
AR

Re:Memory Management -- The Howto (Beginner)

Post by AR »

Warrior wrote:The C runtime lib allocates memory fine and the user actually uses malloc when the need arrises that the runtime library cannot anticipate.
Sort of, the Kernel allocates the process image and loads the process image in (.text, .data and .bss).
>Program needs memory
>Calls malloc() in C library
>malloc() determines there isn't any memory left and it needs another page
>Triggers Kernel syscall for AllocatePage()/ExpandHeap()/brk()
>Kernel allocates another page, attaches it to the process and returns
>malloc() fulfils the request and returns to the program.
All calls to malloc are made directly by the programmer.
Warrior

Re:Memory Management -- The Howto (Beginner)

Post by Warrior »

I thought the String library automaticly allocated memory (on windows AFAIK)
AR

Re:Memory Management -- The Howto (Beginner)

Post by AR »

Yes the C/C++ Runtime library can malloc internally and return that but those functions still need to be called by the programmer, and the programmer still needs to free()/delete.
Post Reply