New issue 346 by jeggerr: Animation uses much memory
http://code.google.com/p/pymt/issues/detail?id=346
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.
Comment #2 on issue 346 by txprog: Animation uses much memory
http://code.google.com/p/pymt/issues/detail?id=346
(No comment was entered for this change.)
Comment #1 on issue 346 by txprog: Animation uses much memory
http://code.google.com/p/pymt/issues/detail?id=346
(No comment was entered for this change.)
Comment #3 on issue 346 by txprog: Animation uses much memory
http://code.google.com/p/pymt/issues/detail?id=346
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.