On 4/19/05, Ley, Chung wrote:
> Hi,
>
> I have a complex data structure using hash of hash of hash that I need to
> hold one unit of
> data that I need to process. After finishing processing this unit, I need to
> go to the 2nd
> unit; each unit will be approx. 10Meg of data.
>
> What is the "quick" and "efficient" way for me to release the memory of the
> previous unit
> so that I can go and reuse it again?
>
> I tried a couple of following methods and neither seem to work.... Please
> let me know if I
> am doing something wrong or should I take another approach...
>
> 1. Just set the hash to "empty"
> my %datahash;
> while (moredetail) {
> $datahash{$level1}{$level2}{$level3}{$level4} = $something;
> }
> &processdata(\%datahash);
>
> %datahash = ();
>
This doesn't release the memory? How do you know?
Have you tried using Devel::Size [1] to see the size of %datahash
after the release?
What about Devel::Monitor [2]?
What happens if you do as the release:
$datahash{$level1}{$level2}{$level3}{$level4} = "";
Does that help?
If all else fails, you might consider using tied hashes. Read:
http://perldoc.perl.org/functions/tie.html
and
http://perldoc.perl.org/Tie/Hash.html
[1] http://search.cpan.org/dist/Devel-Size/
[2] http://search.cpan.org/dist/Devel-Monitor/
HTH,
--
Offer Kaye
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>