[Python-bugs-list] memory leak in loops (PR#398)
ingo.adler@synacon.ch
ingo.adler@synacon.ch
Fri, 14 Jul 2000 05:39:42 -0400 (EDT)
This is a multi-part message in MIME format.
--------------6D29988B97CCE77010389AE2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
> > // The Loop
> > PyRun_SimpleString(
> > "y = Y()\n"
> > "for i in range(1000):\n"
> > "\tx = y.getX()\n"
> > "\tx.getNumber()\n"
>
> Could be that SWIG doesn't get a chance to cleanup the shadow
> object for x and y. Try adding
>
> del x,y
>
> as final script line.
>
> Note that SWIG uses Python strings to represent pointers in
> C++. It uses an internal table to store these.
>
I changed the code to:
PyRun_SimpleString(
"y = Y()\n"
"for i in range(1000):\n"
"\tx = y.getX()\n"
"\tx.getNumber()\n"
"\tdel x\n"
);
It doesn't change anything.
The memory leak only occurs when I call x.getNumber() in the loop. Otherwise x =
y.getX() is memory leak free.
Ingo Adler
--------------6D29988B97CCE77010389AE2
Content-Type: text/x-vcard; charset=us-ascii;
name="ingo.adler.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Ingo Adler
Content-Disposition: attachment;
filename="ingo.adler.vcf"
begin:vcard
n:Adler;Ingo
tel;cell:+41-79-3786792
tel;fax:+41-41-7103244
tel;home:+41-41-7103268
tel;work:+41-41-8111500
x-mozilla-html:FALSE
url:www.synacon.ch
org:Synacon GmbH
adr:;;Rubiswilstrasse 7;Ibach;SZ;6438;Schwitzerland
version:2.1
email;internet:ingo.adler@synacon.ch
title:Dipl.-Inform.
fn:Ingo Adler
end:vcard
--------------6D29988B97CCE77010389AE2--