Task: Allocating and Deallocating Memory
Navigate to the labs/lab-04/tasks/alloc-size/support directory.
-
Use
pmapto analyze the process address space forALLOC_SIZE_KBinitialized to256. Notice the new memory areas and the difference between the use ofmmapsyscall andbrksyscall. -
Use
valgrindon the resulting executable, and notice there are memory leaks. They are quite obvious due to the lack of proper freeing. Solve the leaks. -
Use
valgrindon different executables in the system (in/bin/,/usr/bin/) and see if they have memory leaks.
If you’re having difficulties solving this exercise, go through this reading material.