Skip to content

Instantly share code, notes, and snippets.

@bigpresh
Created July 7, 2015 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigpresh/d1d3589821279a46f552 to your computer and use it in GitHub Desktop.
Save bigpresh/d1d3589821279a46f552 to your computer and use it in GitHub Desktop.
20k hashes memory usage
[davidp@supernova:~]$ cat tmp/hashes.pl
#!/usr/bin/perl
#
use Memory::Usage;
my $mu = Memory::Usage->new();
# Record amount of memory used by current process
$mu->record('before creating hashes');
my @hashes;
for (1..20_000) {
push @hashes, {
one => 'Foo',
two => rand(100),
three => 'Bar',
};
}
# Record amount in use afterwards
$mu->record('after creating hashes');
# Spit out a report
$mu->dump();
[davidp@supernova:~]$ perl tmp/hashes.pl
time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff)
0 6080 ( 6080) 1980 ( 1980) 1584 ( 1584) 1444 ( 1444) 732 ( 732) before creating hashes
0 11056 ( 4976) 6996 ( 5016) 1680 ( 96) 1444 ( 0) 5708 ( 4976) after creating hashes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment