This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Perl bug?


On Jan 22 23:55, Reini Urban wrote:
> Corinna Vinschen schrieb:
> >#!/usr/bin/perl
> >$a = "a" x (100 * 1024 * 1024);
> >sleep 5;
> >$b = "b" x (100 * 1024 * 1024);
> >sleep 5;
> >$c = "c" x (100 * 1024 * 1024);
> >sleep 5;
> 
> ....
> 
> perl is made this way. All vars are still in scope and all vars together 
> require a lot of memory.
> 
> How about:
> #!/usr/bin/perl
> {
>   my $a = "a" x (100 * 1024 * 1024);
>   sleep 5;
> }
> {
>   my $b = "b" x (100 * 1024 * 1024);
>   sleep 5;
> }
> {
>   my $c = "c" x (100 * 1024 * 1024);
>   sleep 5;
> }
> ...
> 
> Than you get better mmap figures.

Hello?  Am I in the wrong movie?

This is no serious application.  I'm demonstrating a problem.

Every allocation uses twice as much memory as necessary.  This is no
problem as long as the process doesn't eat up the virtual memory for
a process.  As soon as no memory is available, I'd expect the GC kicking
in, but it doesn't.  Half of the VM is used up for temporary memory
and never free'd, not even when the VM is used up.  This shows a memory
leak.  The GC apparently doesn't know about this temporary memory
anymore, otherwise it would free it and try to reuse it.  It doesn't.
Use strace and you'll see.  That's not hard to understand, is it?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]