On 13 April 2010 16:25, Patrick Dupre <pd...@york.ac.uk> wrote:
> Hello,
>
> I have the a hash of hash of ... of array
> (see below hwo I can list it) whose i wish to free the memory at one
> point. Right now the desallocation is not clean, ie that evert time that
> I reallocate the hash, the programme requires more and mor space and
> finally swap the memory !
> How can I free the mempry right. I already tried several trivial
> thing without success:
>
> Thank for your help.
>
> foreach my $sig (sort keys %$trans) {
>  foreach my $vt_u (sort keys %{$$trans {$sig}}) {
>    foreach my $Nu (sort keys %{$$trans {$sig}{$vt_u}}) {
>      foreach my $ku (sort keys %{$$trans {$sig}{$vt_u}{$Nu}}) {
>        foreach my $vt_l (sort keys %{$$trans {$sig}{$vt_u}{$Nu}{$ku}}) {
>          foreach my $Nl (sort keys %{$$trans
> {$sig}{$vt_u}{$Nu}{$ku}{$vt_l}}) {
>            foreach my $kl (sort keys %{$$trans
> {$sig}{$vt_u}{$Nu}{$ku}{$vt_l}{$Nl}}) {
>              print "$sig, $vt_u, $Nu, $ku, $vt_l, $Nl, $kl: ", $$trans
> {$sig}{$vt_u}{$Nu}{$ku}{$vt_l}{$Nl}{$kl} [0], " ", $$trans
> {$sig}{$vt_u}{$Nu}{$ku}{$vt_l}{$Nl}{$kl} [1], "\n" ;
>              }
>            }
>          }
>        }
>      }
>    }
>  }

There is no good solution other than not allocating so much memory in
the first place. See perldoc -q "free an array".

Phil

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to