[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] BUG: Memoryleak in pygame.sprite.GroupSingle



Tobias,

Try pygame revision 2953 and confirm that the bug is fixed.
http://thorbrian.com/pygame/builds.php

Thanks!
Jason


From: Lenard Lindstrom <len-l@xxxxxxxxx>
To: pygame-users@xxxxxxxx
Sent: Fri, November 19, 2010 10:56:14 PM
Subject: Re: [pygame] BUG: Memoryleak in pygame.sprite.GroupSingle

Hi,

Yes Tobias, that is right. GroupSingle.draw is inherited from AbstractGroup, which adds each sprite drawn to the spritedict dictionary. It is a bug, though technically not a memory leak since the sprites are still referenced.

Lenard Lindstrom

On 17/11/10 02:48 PM, Jason M. Marshall wrote:
> Tobias,
> Here's my theory: I think that GroupSingle's spritedict dictionary is growing by 1 sprite every time that the draw method is called. The spritedict dictionary is not emptied by GroupSingle, so a reference to each newly-created sprite remains even after a new sprite has been put into GroupSingle. I'll have to test my theory before I'm certain though. If that's the problem, then I'll fix it.
> Jason
>
> ------------------------------------------------------------------------
> *From:* Tobias Steinrücken <t.steinruecken@xxxxxxxxxxxx>
> *To:* pygame-users@xxxxxxxx
> *Sent:* Tue, November 16, 2010 4:18:04 PM
> *Subject:* [pygame] BUG: Memoryleak in pygame.sprite.GroupSingle
>
> Hello,
>
> for me it seems that GroupSingle dosnt release references to the old
> Sprite when a new Sprite is beeing assigned.
>
> ive attached 2 Files.
> pygame_memleak.py actually triggers the leak (Dont uncomment the sleep -
> it will eat your memory instantly!).
> In the second file pygame_memleak2.py i just changed GroupSingle to
> Group and s.sprite = ... to s.empty(); s.add( ... ) to achieve the same
> behaviour as GroupSingle - and this one works fine.
>
>
> Im using:
> Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] (64-Bit)
> Pygame 1.9.1release
> (The default Ubuntu 10.10 setup -but ive seen this on older Versions of
> Python aswell)
> -- Conesoft / Brose - Steinrücken GbR
>
> Ehm. Service4every1
>
> Flemerskamp 19 a 44319 Dortmund
>
> Telefon: +49 (0) 231 / 108722231*
> Fax: +49 (0) 231 / 283798
> E-Mail: t.steinruecken@xxxxxxxxxxxx <mailto:t.steinruecken@xxxxxxxxxxxx>
>
> Gesellschaftsform: Gesellschaft bürgerlichen Rechts
> Sitz: Dortmund
> Geschäftsführer: Roland Brose, Tobias Steinrücken
> USt-IdNr.: DE237763154
>
>