Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2006-12-21 13:28:51 (GMT)
committer Simon Schampijer <simon@schampijer.de>2006-12-21 13:28:51 (GMT)
commit60a40cbf3c9d684b3400da7acd430b14d7082456 (patch)
treed2bbd52772a7b6db526e23bd5022c3de5076caee
parenteb6a799878e434fed0d79e45f65a3cf1bc7d4bc5 (diff)
Well, memosono was adding up memory usage by each click on a tale. This is what a normal human would do as well when playing the memory game;) But the advantag of computers is...just kidding.
The problem was the usage of pixbuf. A new pixbuf was created by each click and the memory did not gets deleted after the object was out of scope. Fixes were the addition of those two lines: del ppixbuf_i gc.collect() Deleting the pixbuf and calling the garbage collector manually. Bug with the best story.
-rwxr-xr-xmemosono.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/memosono.py b/memosono.py
index 5215086..b7e6471 100755
--- a/memosono.py
+++ b/memosono.py
@@ -31,6 +31,8 @@ import random
import copy
import time
import errno
+import gc
+
from sugar.activity.Activity import Activity
class Server:
@@ -346,9 +348,13 @@ class View:
# scale black
self.scale_x = 200
self.scale_y = 200
- self.pixbuf_i = gtk.gdk.pixbuf_new_from_file(os.path.join(self._MEMO['_DIR_IMAGES'],"black80.jpg"))
- self.scaledbuf_i = self.pixbuf_i.scale_simple(self.scale_x, self.scale_y, gtk.gdk.INTERP_BILINEAR)
+ pixbuf_i = gtk.gdk.pixbuf_new_from_file(os.path.join(self._MEMO['_DIR_IMAGES'],"black80.jpg"))
+ self.scaledbuf_i = pixbuf_i.scale_simple(self.scale_x, self.scale_y, gtk.gdk.INTERP_BILINEAR)
+ ### fix to release the memory allocated by the pixbuf call
+ del pixbuf_i
+ gc.collect()
+
self.y = 0
self.x = 0
i = 0
@@ -393,12 +399,17 @@ class View:
def pixbuf(self, filename, pictype, pscale_x, pscale_y):
if pictype is 1:
- self.ppixbuf_i = gtk.gdk.pixbuf_new_from_file(os.path.join(self._MEMO['_DIR_GIMAGES'],filename))
+ ppixbuf_i = gtk.gdk.pixbuf_new_from_file(os.path.join(self._MEMO['_DIR_GIMAGES'],filename))
if pictype is 0:
- self.ppixbuf_i = gtk.gdk.pixbuf_new_from_file(os.path.join(self._MEMO['_DIR_IMAGES'],filename))
+ ppixbuf_i = gtk.gdk.pixbuf_new_from_file(os.path.join(self._MEMO['_DIR_IMAGES'],filename))
- self.pscaledbuf_i = self.ppixbuf_i.scale_simple(pscale_x, pscale_y, gtk.gdk.INTERP_BILINEAR)
- return self.pscaledbuf_i
+ pscaledbuf_i = ppixbuf_i.scale_simple(pscale_x, pscale_y, gtk.gdk.INTERP_BILINEAR)
+
+ ### fix to release the memory allocated by the pixbuf call
+ del ppixbuf_i
+ gc.collect()
+
+ return pscaledbuf_i
def _next(self, controler, playername, filename, lastplayer, lastfilename):
self.p_imageObj[playername].set_from_pixbuf(self.pixbuf(filename, 0, self.pscale_x, self.pscale_y))