Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to see how much memory a variable uses?

I am working with Perl for some months now. As for now, my scripts work but they are far from being perfect.

I would now like to optimize the memory usage, thus I am looking for a way to break down the memory usage per variable/hash.

Is there a way to see how much memory a variable uses?

like image 716
grosseskino Avatar asked Aug 22 '11 09:08

grosseskino


2 Answers

Devel::Size or Devel::Size::Report can be used to get memory usage for a variable/structure.

You might want to check perl guts illustrated to see what the numbers really mean.

like image 93
bvr Avatar answered Oct 19 '22 06:10

bvr


Have a look at Devel::Size on CPAN.

like image 33
holygeek Avatar answered Oct 19 '22 06:10

holygeek