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. 😁

Source

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();

​#Programming ​#Memory ​#Perl