mansrz / pymt

Automatically exported from code.google.com/p/pymt
0 stars 0 forks source link

Animation uses much memory #346

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
sample code:

from pymt import *
from os.path import join
import random

class screen_saver_window(MTWidget):
    def __init__(self, **kwargs):
        super(screen_saver_window, self).__init__(**kwargs)  
        self.img = Loader.image(join("buildings/1.png"))
        self.window=MTContainer(self.img)
        self.load_window()

    def load_window(self):
        self.window.pos=(random.randrange(0, 1000, 2), random.randrange(800, 5000, 2))
        self.add_widget(self.window)
        self.animate_window()

    def unload_window(self):
        self.remove_widget(self.window)

    def animation_complete(self, touch):
        del self.flyanimation
        self.unload_window()
        self.load_window()

    def animate_window(self):
        self.flyanimation = Animation(duration = 10 , pos=(self.window.x, -500))
        self.flyanimation.connect('on_complete', self.animation_complete)
        self.window.do(self.flyanimation)

test=screen_saver_window()
getWindow().add_widget(test)        
if __name__ == '__main__':
    runTouchApp()

What is the expected output? What do you see instead?
After a time, the animation begins to lag. 

What version of the product are you using? On what operating system?
PyMT 0.5.1, OsX10.6.4

Please provide any additional information below.
When I run this code with the animation, python use with the time more and more 
memory (as I see in the activity Monitor on MacOS). The animation begins to lag 
after 10-15minutes.

There is probably some reference to an object that should be deleted.

Original issue reported on code.google.com by jegg...@gmail.com on 17 Oct 2010 at 1:40

GoogleCodeExporter commented 9 years ago

Original comment by txprog on 17 Oct 2010 at 2:49

GoogleCodeExporter commented 9 years ago

Original comment by txprog on 17 Oct 2010 at 2:49

GoogleCodeExporter commented 9 years ago
Ok, after a long and not cool debugging... it appear that the default caching 
option is not suitable for your case. (We are caching an empty display list 
even if no drawing instruction are done. That's bad, but resolved when moving 
on graphics API.)

After importing pymt, you can do:

Cache.register('pymt.cssrect', limit=100, timeout=2)

This will reduce the caching to cache data maximum 2 seconds.

Original comment by txprog on 17 Oct 2010 at 8:14