Understanding Malloc() Internals: What I've Learnt So Far
Intro I've been learning C language, and used malloc() multiple times as an inbuilt function. I was curious about what work it actually did under the hood and how did it actually allocate memory. So I did some research, and watched a couple of videos on youtube.. this was one of the videos that was very useful. https://youtu.be/HPDBOhiKaD8?si=T4HeEA3ACE3macqO This post documents everything that I have learnt so far. This is a work-in-progress, i will continue updating this post as i get more knowledge about this topic. What is Malloc() malloc() is a C function that is used to allocate memory for a program. You can access the system heap using the inbuilt C function: malloc(). It tries to give your program a chunk of memory that is large enough to hold size bits. Concepts Memory is the address space that is in the RAM or swap. Accessing Heaps in C Heaps can be accessed in C using sbrk() -> main heap nmap() -> additional ...