develooper Front page | perl.beginners | Postings from April 2022

Re: Please help: perl run out of memory

Thread Previous | Thread Next
From:
David Emanuel da Costa Santiago
Date:
April 27, 2022 21:05
Subject:
Re: Please help: perl run out of memory
Message ID:
4c9e5a61-4fe4-542d-6d67-716ad0681809@gmail.com


Às 11:33 de 17/04/22, wilson escreveu:
> hello the experts,
> 
> can you help check my script for how to optimize it?
> currently it was going as "run out of memory".
> 
> $ perl count.pl
> Out of memory!
> Killed
> 
> 
> My script:
> use strict;
> 
> my %hash;
> my %stat;
> 

To be honest you don't need the %stat, however you'll need to go through 
the %hash several times for the average calculation. It will also make 
the script more unreadable.

You can also read the file several times, and on each time extract only 
the values of only one item.

The best option is for you to use a profiler to figure it out where the 
most memory is being consumed...


Good luck.

Regards,
David Santiago

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About