$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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |