delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/01/22/14:26:42

X-Spam-Check-By: sourceware.org
Message-ID: <1552.67.40.28.188.1169493973.squirrel@67.40.28.188>
In-Reply-To: <20070122181727.GC27843@calimero.vinschen.de>
References: <20070122181727 DOT GC27843 AT calimero DOT vinschen DOT de>
Date: Mon, 22 Jan 2007 11:26:13 -0800 (PST)
Subject: Re: Perl bug?
From: "Yitzchak Scott-Thoennes" <sthoenna AT efn DOT org>
To: cygwin AT cygwin DOT com
User-Agent: SquirrelMail/1.5.0
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

> Hi,
>
> consider the following statement:
>
>  $a = "a" x (100 * 1024 * 1024)
>
> When you create a script which does this over and over again, you'll
> observe a strange memory problem.

Can you show your script?

> By stracing I found that for each of these statements the following
> happens:
>
>  "a"         --> malloc (2 bytes)
>  x 100 Megs  --> realloc (100 Megs) + malloc (100 Megs)
>
> So the result is that each string of 100 Megs requires 200 Megs of
> memory.  Doing this once is no problem, but doing it over and over
> again will hit the maximum memory available twice as early.

This is as I would expect.  Most operators have a target, a temporary
lexical, allocated to store their results.  Like all lexicals, these
hold on to any memory they have allocated in the hope of saving having
to allocate it a second time.

> I can only assume that either the garbage collector doesn't kick in when
> it should, or the garbage collector doesn't even know about this wasted
> memory, which would be a generic memory leak either way.  However, it's
> not clear if this depends on the Perl version, or if it depends on the
> 64 bit int setting when building Perl.

I'd more likely suspect differences in the usemymalloc setting (perl
-V:usemymalloc).  I'm not clear on exactly what you are seeing; again,
I'd like to see your test script.

-- 
I'm looking for a job: http://perlmonks.org/?node=ysth#looking


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019