How to detect memory usage in hash?

S

sonet

How to know how many memory usage in a hash??
I just can use top to see the memory usage?

-----How to rough estimate ?---

my %hash;
for (my $i=0;$i<=10000;$i++){
$hash{abc}{$i}='testing';
}
 
G

Gregory Toomey

sonet said:
How to know how many memory usage in a hash??
I just can use top to see the memory usage?

-----How to rough estimate ?---

my %hash;
for (my $i=0;$i<=10000;$i++){
$hash{abc}{$i}='testing';
}

For a non-portable linux solution, read /proc/$$/status, and look for a line
with 'VmSize'.

gtoomey
 
X

xhoster

sonet said:
How to know how many memory usage in a hash??

That depends on many things.
I just can use top to see the memory usage?

Sure, if your system has top. Of course, it will be memory of the
entire perl program, not just the hash. To do it from withing Perl,
I usually use "my $mem = (`ps -p $$ -o rss `)[1];", which gives just the
resident size of the whole program, but is usually good enough.
There is also Devel::Size, but I often find it to be unreliable and that
it causes worse problems than the ones I'm trying to use it to solve.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top