Ok, I will try but it's difficult because of length and logic of my code. First of all - what does my script do? It takes one line of structured string, parses that string and stores it in hash that looks like:
 $VAR1 = {
          '0' => {
                   'type' => ...,
                   'value' => ...
                 },
          '1' => {
                   'type' => ..,
                   'value' => ...
                 },
          '2' => {
                   'type' => ...,
                   'value' => ...
                 },
          '3' => {
                   'type' => ...,
                   'value' => ...
                 },
          '4' => {
                   'lvalue' => ...,
                   'rvalue' => ...,
                   'rvalue_type' => ...,
                   'type' => ...
                 }
        };
The aim of script is to generate more (similar in some way) hashes. I store these hashes in array. The main action is generation and it looks like:
    my $elements_ref = shift; # reference to AoH which at the beginning contains one element
    
    %el = %{$elements_ref->[0]}; # Take first element of AoH
    my @hitlist; # Stores hash keys that indicate hash elements I will change
    
    # ...
    # Fill @hitlist with hash keys that I need. Simple for loop.
    # ...
    
    my $k = @hitlist; # Size of @hitlist. In this case it is equal to 3
    
    my $iter = Algorithm::Combinatorics::variations_with_repetition($new, $k); # Give me all variations of some elements
    
    while (my $var = $iter->next)       
    {
        my $new_el= Storable::dclone \%el;
        
        # Now, for each variation I will create (clone) original %el
        # and in $new_el I will substitute $k elements of hash indicated
        # by keys contained in @hitlist
        
        for (my $j = 0; $j < $k; $j++)
        {   
            my $hit = $hitlist$j;
            
            # ...
            $new_url->... = $var->$j;
            # ...
        }
        
        push @$elements_ref, $new_el; # Store new element in AoH
    } 
And the problem is that when at the end I store AoH in hdd it takes 8mb, but while generating it takes 130mb of ram.

In reply to Re^2: Issue with cloning and large structure processing by scathlock
in thread Issue with cloning and large structure processing by scathlock

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.