2021-06-21 Memory leaks without using top

I heard many times that using ‘top’ to measure process memory usage was not recommended. Most of the time, memory isn’t returned to the operating system immediately. My guess is that using ‘ps’ is similarly unreliable. So now what?

Recently, I came upon a page about ‘kitty’ where the author argues against the use of ‘tmux’ – but I’m not interested in that. What I care about is that he explains how to measure memory usage using ‘valgrind’. Let’s see. He’s interested in ‘kitty’ as I said, so replace it with whatever you are interested in.

Run the program under valgrind:

PYTHONMALLOC=malloc valgrind --tool=massif kitty

Then visualize what’s going on:

massif-visualizer massif.out.*

Right. This is for future reference. 😁

Perl

Test::LeakTrace offers the following:

# standard test interface
use Test::LeakTrace;
 
no_leaks_ok{
    # ...
} 'no memory leaks';

Test::Valgrind offers the following:

# In a test file
use Test::More;
eval 'use Test::Valgrind';
plan skip_all => 'Test::Valgrind is required to test your distribution with valgrind' if $@;
leaky();

Comments


Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Just say HELLO