in reply to Improving memory performance
You might be tempted to do something along the lines of:
my @newlist = &perform_fancy_op(@list);
But this has the side effect of pushing all of the list elements into the stack (hence, potentially growing the stack segment and your memory footprint) and also allocating a new list for the result.
If you can throw the old contents of @list, perhaps you could change your code to do something like:
&perform_efficient_op(\@list);
In this form, you only pass a reference to the whole list (a scalar) and could probably operate on the old list in place, saving the memory required for the additional copies of the list going up and down your stack.
This will usually make your code faster too, specially when dealing with long lists.
Regards.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Improving memory performance
by Sihal (Pilgrim) on Oct 04, 2002 at 08:06 UTC |