Shows how much memory the data structure uses.

I have a huge hash containing daily statistics for 10 years. Is there a way in Perl 6 to determine how much real memory (in bytes) this hash is used (for example, showMemoryUsed(%myBigHash)). Even if %myBigHashempty, these are not null bytes due to the memory used and the Perl 6 hash data type implementation. This information will tell me if I need to re-implement my codes or periodically write to a file to reduce the lack of RAM (my program runs on virtual Linux with 2G RAM).

Thanks.

+6
source share
1 answer

, Rakudo Perl 6. , , - Telemetry:

use Telemetry;
my $before = T<max-rss>;
my %h = ...; # initialize hash
say "Memory usage grew { T<max-rss> - $before } KB";

Telemetry : https://docs.perl6.org/type/Telemetry

+5

All Articles