Skip to main content

3 posts tagged with "memory"

View All Tags

ideas of memory pool

· One min read

the key information to implement a memory pool

  • boundary:

How to solve the boundaries between different different chunks

  • name:

How to get an allocated memory chunk

  • reference count

whether the chunk is still used. I want to free the memory only if the process termination or free, with threads free, only do reference count minus 1.

  • data structure:

which data structure will be efficient?

memory leak

· One min read

find memory leak of a running process

$ cat /proc/$pid/smaps
  1. find out the PID of the process
$ ps -aux
  1. capture /proc/PID/smaps and save into some file like before_meminc.txt
  2. wait till memory gets increased
  3. try again step 2
  4. find the difference between first smaps and 2nd smaps, e.g. with
$ diff -u before_meminc.txt after_meminc.txt
  1. note down the address range where memory got increased

  2. use pstack and watch command to get the right call stack

$ watch -n 1 'pstack $PID | tee -a $PID.stack'

C-c when we caputred right stack

  1. check our stack file, find the functions between address range which we got from step 6.