in reply to How to free memory used by previous program?

I am not getting any of free memory to use. What are the possible ways that can serve me the purpose.

The short simple answer is to fork off the memory intensive operation and collect the results thru a pipe or some other perlipc. When you use threads, there is always the chance for memory accumulation. When you fork, you get a new pid, and when that pid is destroyed, ALL memory is returned.

For example, the following code was posted awhile back to demonstrate how easy it is to fork and collect data.

#!/usr/bin/perl use strict; use warnings; use Parallel::ForkManager; my $pm = Parallel::ForkManager->new(2); $pm->run_on_finish( sub { # result from the child will be passed as 6th arg to callback my $res = $_[5]; # p $res; print "$res\n"; } ); for (1..3) { $pm->start and next; # from here and till $pm->finish child process running # do something useful and store result in $res my $res = { aaa => $_ }; # this will terminate child and pass $res to parent process $pm->finish(0, $res); } $pm->wait_all_children;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh