Read: Investigate Memory Actions
Memory actions generally mean:
- memory access: read, write or execute
- memory allocation
- memory deallocation
By far, the most important actions are allocation and deallocation. Because, if not done right, these can get to memory loss and poor memory use.
Memory loss generally happens in the form of memory leaks.
malloc() in Musl
Each libc (or memory allocator such as jemalloc) uses their own implementation of malloc(), free() and other functions. Musl libc is a lightweight standard C library that provides compatible features with the more heavyweights GNU libc.
Take a look through implementation of malloc() and free() in Musl libc. See all three implementations for malloc():
- the one in
lite_malloc.c - the one in
mallocng/malloc.c - the one in
oldmalloc/malloc
See also the implementation of free(). And the implementation of calloc().
You needn’t spend too much time browsing the implementation of these functions, just having a broad understanding of how they work.