
Understanding Malloc() Internals: What I've Learnt So Far
Intro In my first year, I learnt C language, and have used malloc() multiple times in a program. 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. The Heap: what does malloc() do? - bin 0x14 by LiveOverflow 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() -> to access main heap mmap() -> to access the additional heap Note: when you re
Continue reading on Dev.to
Opens in a new tab



