Issue 169 in los-cocos: Tile maps cause memory leaks

23 views
Skip to first unread message

codesite...@google.com

unread,
Oct 2, 2011, 11:54:32 AM10/2/11
to cocos-...@googlegroups.com
Status: New
Owner: ----

New issue 169 by davexu...@gmail.com: Tile maps cause memory leaks
http://code.google.com/p/los-cocos/issues/detail?id=169

What steps will reproduce the problem?
1. Run the code below (put the .py file in the test/ directory as it is
based off of the test_tiles.py test)
2. Open top or another process manager and watch as memory consumption goes
up.

Here is the test:
# This code is so you can run the samples without installing the package
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

import pyglet
from pyglet.window import key
from pyglet.gl import *

pyglet.resource.path.append(pyglet.resource.get_script_home())
pyglet.resource.reindex()

import cocos
from cocos import tiles, actions, layer, scenes

def make_scene():
scroller = layer.ScrollingManager()
test_layer = tiles.load('road-map.xml')['map0']
scroller.add(test_layer)

return cocos.scene.Scene(scroller)


if __name__ == "__main__":
from cocos.director import director
director.init(width=600, height=300, do_not_scale=True, resizable=True)

def new_scene(dt):

director.replace(cocos.scenes.transitions.FadeTransition(make_scene(), 1))
pyglet.clock.schedule_interval(new_scene, 3)

director.run(make_scene())

What is the expected output? What do you see instead?
The output is correct but I expect the tile map data to be garbage
collected but it doesn't seem to be happening. As far as I can tell, other
layers that I have used do not have this issue. Memory output jumps up
around 10MB for each scene change and the program quickly uses hundreds of
MB of memory.


What version of the product are you using? On what operating system?
Tested on 0.4.0 and 0.5.0rc0

codesite...@google.com

unread,
Oct 2, 2011, 11:58:33 AM10/2/11
to cocos-...@googlegroups.com

Comment #1 on issue 169 by davexu...@gmail.com: Tile maps cause memory leaks
http://code.google.com/p/los-cocos/issues/detail?id=169

Forgot to mention operating system. I am using Arch Linux.

codesite...@google.com

unread,
Oct 3, 2011, 12:31:12 AM10/3/11
to cocos-...@googlegroups.com
Updates:
Status: Accepted
Labels: Type-Defect

Comment #2 on issue 169 by ccanepacc: Tile maps cause memory leaks
http://code.google.com/p/los-cocos/issues/detail?id=169

Confirmed in windows xp sp3, python 2.6.6, cocos 0.5rc0, pyglet 1.2dev and
pyglet 1.1.4 release.
Eliminating the transition does not help.
Need to investigate.

codesite...@google.com

unread,
Oct 29, 2011, 1:10:31 PM10/29/11
to cocos-...@googlegroups.com
Updates:
Owner: ccan...@gmail.com

Comment #3 on issue 169 by ccan...@gmail.com: Tile maps cause memory leaks
http://code.google.com/p/los-cocos/issues/detail?id=169

Ok, the ultimate cause is that both ScrollingManager and ScrollableLayer
are doing
director.push_handlers(self.on_cocos_resize)
in their on_enter method, but not a balancing pop in on_exit.
That keeps references to the instances in director._event_stack even when
the scene goes inactive.

If we add a pop at on_exit, the layers will miss notifications about window
resize while they are inactive, so we need to ensure that at each on_enter
we have code that handles resizes that happened when the nodes were not in
the active scene.

I will look at the code and modify some test(s) in issue 153 (they exercise
scrolling, both with and without tilemaps), then look for well behaved
fixes.

codesite...@google.com

unread,
Feb 26, 2012, 11:54:05 AM2/26/12
to cocos-...@googlegroups.com
Updates:
Status: TrunkFixed
Labels: OpSys-All Component-Tiles

Comment #4 on issue 169 by ccan...@gmail.com: Tile maps cause memory leaks
http://code.google.com/p/los-cocos/issues/detail?id=169

fixed at r1169

attached specific test, fails with r1168, pass with r1169

codesite...@google.com

unread,
Aug 13, 2012, 8:52:44 PM8/13/12
to cocos-...@googlegroups.com
Updates:
Status: Fixed

Comment #5 on issue 169 by ccan...@gmail.com: Tile maps cause memory leaks
http://code.google.com/p/los-cocos/issues/detail?id=169

fixed in cocos 0.5.5, closing

codesite...@google.com

unread,
Aug 14, 2012, 1:36:34 PM8/14/12
to cocos-...@googlegroups.com

Comment #6 on issue 169 by dthomps...@worcester.edu: Tile maps cause memory
leaks
http://code.google.com/p/los-cocos/issues/detail?id=169

Thank you! :)

Reply all
Reply to author
Forward
0 new messages