On Tue, Oct 21, 2008 at 11:08, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > On Mon, 2008-10-20 at 23:29 -0700, kenTk wrote: >> If I populate @array >> Then >> @array=(); >> Is the memory that was used for that array now freed? > > Yes, providing no other variable contains those items. For example: snip
Not necessarily, even if it is garbage collected perl might not return the memory to the system. The perl interpreter will most likely hold onto that memory for its own future use. The only protection against this is to use as little memory as possible. snip > my @a = qw( a b c ); > my @b = @a; > @a = (); > > Since @b contains everything is @a, its contents are not freed until the > contents of @b are replaced. snip @b contains copies of what is in @a, not references; therefore emptying @a has no effect on @b. If you had said @b = map { \$_} @a; then your statement makes sense. >> >> Similarly >> If I populate the anonymous array @{$arrayREFS[$index]} >> Then >> @{$arrayREFS[$index]}=(); >> Is the memory that was used for that anonymous array now freed? > > Yes but as above. snip No, as above. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/