> -----Original Message----- > From: Jenda Krynicky [mailto:[EMAIL PROTECTED] > Sent: Tuesday, May 25, 2004 8:08 PM > To: [EMAIL PROTECTED] > Subject: RE: Question of memory management in Perl > > > From: [EMAIL PROTECTED] > > I don't know for sure the effect of: > > > > @out_array_bin = map {""} (@out_array_bin); > > > > instead of > > > > for ($init_cnt=0;$init_cnt<=$#out_array_bin;$init_cnt++) { > > $out_array_bin[$init_cnt] = ""; > > } > > > > But is more readable. > > Neither makes much sense. > And the map based one is actually even more memory hungry. > > @out_array_bin = (); > or > undef @out_array_bin; > > will clear the array completely and will be much quicker. > > The problem with the for(){} is that it doesn't get rid of the whole > array, just the values of the elements. So you end up with a huge > array containing empty strings. Which will take up quite some memory. > > The map{} is even worse because instead of "clearing" the array "in > place" it creates a new huge array containing the empty strings. So > at one point you have two huge arrays. One containing the data and > the other containnig the empty strings :-( > > Jenda
I supose that the end result of: for ($init_cnt=0;$init_cnt<=$#out_array_bin;$init_cnt++) { $out_array_bin[$init_cnt] = ""; } and '@out_array_bin = ();' or 'undef @out_array_bin;' is not the some, is it? In the memory probably I write in the first parte of the mail. This was a cleaner code than the one he had not consedering the memory problem. when I wrouth "I don't know for sure the effect of" was considering the time effect not the memory question. Sory if I was not clear. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>