Re: memory doesn't free after lexical block

2011-05-19 Thread marcos rebelo
What is being told in here, is that: foreach my $m (1..1e7 ) { my @array; foreach my $n (1..1e7 ) { push @array, $n; } print "in\n"; } print "sleeping\n"; sleep 600; Stops growing in memory. In normal execution, when the memory is no longer used, the OS will cache it. Bes

Re: memory doesn't free after lexical block

2011-05-19 Thread Shawn H Corey
On 11-05-19 01:39 AM, Sheppy R wrote: how would you change the original code to get it to free up memory? Put the processing in a sub-process. When it dies, the memory is returned to the system. See: perldoc -f fork perldoc perlipc -- Just my 0.0002 million dollars worth, Shawn Con

Re: memory doesn't free after lexical block

2011-05-18 Thread Uri Guttman
> "JG" == Jim Green writes: JG> I have a quick question about memory release in perl: JG> { JG> my @array; JG> foreach my $n (1..1e7 ) { JG> push @array, $n; JG> print "$n\n"; JG> } JG> } someone asked about the original code. this is a silly exa

Re: memory doesn't free after lexical block

2011-05-18 Thread Uri Guttman
> "SR" == Sheppy R writes: SR> Uri, how would you change the original code to get it to free up SR> memory? I've run into this issue myself quite a few times. I've SR> also seen perl consume an entire cpu core without even trying. SR> Could you rework the original scriptlet to show

Re: memory doesn't free after lexical block

2011-05-18 Thread Sheppy R
Uri, how would you change the original code to get it to free up memory? I've run into this issue myself quite a few times. I've also seen perl consume an entire cpu core without even trying. Could you rework the original scriptlet to show how you would free the memory at the end or direct us to

Re: memory doesn't free after lexical block

2011-05-18 Thread Uri Guttman
> "JG" == Jim Green writes: JG> On 18 May 2011 20:39, Shawn H Corey wrote: >> On 11-05-18 08:36 PM, Jim Green wrote: >>> >>> is this the same for other language like c++ or java? >> >> For all processes.  That's why deamons periodically respawn; to clean up >> messes like thi

Re: memory doesn't free after lexical block

2011-05-18 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> On 11-05-18 08:36 PM, Jim Green wrote: >> is this the same for other language like c++ or java? SHC> For all processes. That's why deamons periodically respawn; to clean SHC> up messes like this. again, somewhat incorrect. a properly well writt

Re: memory doesn't free after lexical block

2011-05-18 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> On 11-05-18 08:25 PM, Jim Gibson wrote: >> Perl hangs on to the memory and does not return it back to the operating >> system. SHC> Under UNIX, et al. all processes hang on to their memory because it's SHC> too time consuming to give it back.

Re: memory doesn't free after lexical block

2011-05-18 Thread Jim Green
On 18 May 2011 20:39, Shawn H Corey wrote: > On 11-05-18 08:36 PM, Jim Green wrote: >> >> is this the same for other language like c++ or java? > > For all processes.  That's why deamons periodically respawn; to clean up > messes like this. Thank you! I just wish this is not a deficiency in Perl

Re: memory doesn't free after lexical block

2011-05-18 Thread Shawn H Corey
On 11-05-18 08:36 PM, Jim Green wrote: is this the same for other language like c++ or java? For all processes. That's why deamons periodically respawn; to clean up messes like this. -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Progra

Re: memory doesn't free after lexical block

2011-05-18 Thread Jim Green
On 18 May 2011 20:30, Paul Johnson wrote: > On Wed, May 18, 2011 at 05:16:23PM -0700, Jim Green wrote: >> Hello List! >> I have a quick question about memory release in perl: >> >> { >>     my @array; >> >>     foreach my $n (1..1e7 ) { >>         push @array, $n; >>         print "$n\n"; >>     }

Re: memory doesn't free after lexical block

2011-05-18 Thread Paul Johnson
On Wed, May 18, 2011 at 05:16:23PM -0700, Jim Green wrote: > Hello List! > I have a quick question about memory release in perl: > > { > my @array; > > foreach my $n (1..1e7 ) { > push @array, $n; > print "$n\n"; > } > } > > print "sleeping\n"; > sleep 600; > > after

Re: memory doesn't free after lexical block

2011-05-18 Thread Shawn H Corey
On 11-05-18 08:25 PM, Jim Gibson wrote: Perl hangs on to the memory and does not return it back to the operating system. Under UNIX, et al. all processes hang on to their memory because it's too time consuming to give it back. -- Just my 0.0002 million dollars worth, Shawn Confusion

Re: memory doesn't free after lexical block

2011-05-18 Thread Jim Gibson
On 5/18/11 Wed May 18, 2011 5:16 PM, "Jim Green" scribbled: > Hello List! > I have a quick question about memory release in perl: > > { > my @array; > > foreach my $n (1..1e7 ) { > push @array, $n; > print "$n\n"; > } > } > > print "sleeping\n"; > sleep 600; > >

memory doesn't free after lexical block

2011-05-18 Thread Jim Green
Hello List! I have a quick question about memory release in perl: { my @array; foreach my $n (1..1e7 ) { push @array, $n; print "$n\n"; } } print "sleeping\n"; sleep 600; after the code block, I epxect memory usage to drop to almost zero because @array went out of sc