Many times we use IO::Socket module to establish sockets in code and while creating a object using following code snippet:-
my $output=<$socket> ;
This all was done using multi threading in a while(1) loop and the moment code was executed it started to consume a whopping 265MB memory. This increased gradually to almost 600MB and finally eat up the 2.5GB swap memory and thus was memory overflow.
We have searched inside out of numerous forums and found a thread that had almost the same issue we had. Thus we went through the details and found an issue a very interesting fact about sockets.
It stated the fact that these sockets have a circular reference in them. And that clicked and then we simply placed a single liner to fix this bug:-
After making above changes our code started consuming memory much lesser than the previous one. It was playing around 125-150MB and didn’t go beyond that value.
This valuable FIX is shared by my friend and colleague “Hussain Dahodwala” who works in Research and Development wing of ESDS.