user1418706
user1418706

Reputation: 202

Checking available heap memory dynamically from Perl

I am running into the need to better balance my octrees based not just on spacial distribution but also on memory usage per branch. Whats the best way in Perl to check memory usage per object generated and then as a ratio of memory available to that process ?

Upvotes: 2

Views: 298

Answers (1)

user3243135
user3243135

Reputation: 820

Try the total_size function in Devel::Size:

use Devel::Size qw/total_size/;
print total_size {
    a => [1,2,4],
    b => [{
            x => 2,
            y => 3,
        }, undef, 123],
    c => 123,
}
# 975

You can get available memory from /proc/meminfo on linux.

Upvotes: 2

Related Questions