I am processing them one by one, it appears that perl keeps chewing space anyways. Here's the relevant section of code:
foreach (sort keys %tickets) { my $ticket = ((split " ",$_)[0]); my %tick_inf; #hash to hold ticket info (%tick_inf = ars_GetEntry($rem,$schema,$ticket)) || warn "Could not retrieve $ticket: $ars_errstr"; #populat +e the hash with the ticket info my $field_data=$ticket; foreach (@$afield_names){ #these are the fields that we have be +en asked to grab. $field_data .= " " . $sep; #join the previous d +ata with the seperator unless (exists $hfield_names->{$_}) { print "Bad field name -- $_\n"; next; } unless (exists $tick_inf{$hfield_names->{$_}}) { print $hfield_names->{$_} . "\n"; print "Bad ticket info identifier -- $_ does not relate to +: " . $hfield_names->{$_} . "\n"; next; } unless ( defined($tick_inf{$hfield_names->{$_}})) { $field_data .= " "; next; } if (ref($tick_inf{ $hfield_names->{$_} }) eq "ARRAY") #For +array references { my $data; foreach (@{ $tick_inf{ $hfield_names->{$_} } }) #foreach o +f the values of the array ref { $data .= expand_hash($_); #it's always a hash, +so expand it out (sub returns a string) } $field_data .= $data; next; #and hit the next value } if ($d_fields->{$_}) #For dates { $field_data .= format_date( $tick_inf{ $hfield_names->{$_} } ); #format the date (sub routine) next; #and hit the next value } if ($l_fields->{$_}) #if the field is a sel +ection value { $field_data .= $l_fields->{$_}->{ #change number i +nto the name: $tick_inf{ #fill the data from the $lis +t field hash $hfield_names->{$_} # } # }; next; } $field_data .= $tick_inf{ $hfield_names->{$_} }; # #value is in the ticket }#close foreach @$fields #more stuff which gets rid of $field_data }
UPDATE: I added a } to properly denote the end of the foreach (@$afields) loop. It is redefined at the beginning of each ticket (foreach sort keys %tickets) {}. Sorry about the bad formatting, this is what happens when you cut and paste code. The problem is not in the $field_data (IMHO)

Note that before running this foreach loop the memory usage is relatively low (~40 meg). As this portion of the script runs the memory continues to increase (not an increase, then drop, then increase again). After this foreach loop we dump $field_data to a file and "undef" it.

So, is there a bug that I am not seeing in there? Is there some reason that this code is chewing up so much space?

In reply to Re: Re: Memory usage & hashes of lists of hashes of lists by the_slycer
in thread Memory usage & hashes of lists of hashes of lists by the_slycer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.