On Tue, Jun 3, 2008 at 2:02 PM, alex23 <[EMAIL PROTECTED]> wrote:
>
> Hey everyone,
>
> The following piece of code appears to keep consuming memory for the
> duration of its runtime, at least under Windows XP. I hadn't noticed
> it until I cranked up the number of animated sprites on screen at one
> time, at which point performance began to slowly crawl the longer it
> was run. I _think_ I'm handling everything correctly, but would
> appreciate some feedback before filing it as an actual bug report.
> Here's an example that leaks on my machine:
> ----
>
> import pyglet
> from pyglet import resource, window
> from pyglet.sprite import Sprite
>
> resource.path = ['res']
> resource.reindex()
>
> batch = pyglet.graphics.Batch()
>
> z_order = lambda x: pyglet.graphics.OrderedGroup(x)
> Z_BACK  = z_order(0)
> Z_ENEMY = z_order(1)
>
> def load_anim(imagename, rows, cols, row_pad=0, col_pad=0,
> framerate=0.1):
>    img = resource.image(imagename)
>    map = pyglet.image.ImageGrid(img, rows, cols,
>        row_padding=row_pad,
>        column_padding=col_pad
>        )
>    return map.get_animation(framerate, loop=True)
>
> enemy_image = load_anim('tyrian_ship_01.png', 1, 8, 0, 10)
>
> class Game(pyglet.window.Window):
>    def __init__(self):
>        super(Game, self).__init__(800, 600, caption="memleak test",
> visible=False)
>        self.background = Sprite(resource.image('planet2.png'),
>            batch=batch, group=Z_BACK
>            )
>        self.enemy = Sprite(enemy_image, batch=batch, group=Z_ENEMY)
>        self.enemy.set_position(400,300)
>
>    def on_draw(self):
>        self.clear()
>        batch.draw()
>
>    def start(self):
>        self.set_visible(True)
>        pyglet.app.run()
>
> if __name__ == '__main__':
>    game = Game()
>    game.start()
>
> ----
>
> If I replace the animation with a static sprite like so:
>
> enemy_image = resource.image('tyrian_ship_01.png')
>
> ...no further memory is used after the program runs. But with the
> animation, it steadily ticks over without halt.
>
> Am I doing something blatantly wrong here that could be causing it?

Thanks, good catch.  The problem was a memory leak in pyglet.clock,
now fixed in r2100.

Alex.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to