python - Pymunk Memory leak and/or Hangs -


i've been writing game in python requires being able add , remove lot of objects physics engine. in extreme testing scenarios can run out of memory seconds. in normal cases take while accumulate. after 2 days of work found small test scenario displays whats happening. platform windows 7 64x.

import pymunk import time os import system space=pymunk.space() width=5 height=5 poly=[(-width/2.0,-height/2.0),(-width/2.0,height/2.0),(width/2.0,height/2.0),(width/2.0,-height/2.0)] while(true):     #time.sleep(.5) #     system("pause")     bodys=[pymunk.body(mass=5,moment=pymunk.moment_for_poly(5, poly)) in range(200)] #num of objects here     print "1"     shapes=[pymunk.poly(bod, poly) bod in bodys]     print "2"     space.add(bodys)     print "3"     space.add(shapes)     print "4"     space.step(.5) #step has no effect on leak     print "5"     space.remove(space.bodies)     print "6"     space.remove(space.shapes)     print "7"     #space.remove(shapes)     #print "6"     #space.remove(bodys)     #print "7" 

so if play around little. there time didn't hang , climb outta memory. hangs @ removing shapes. neither shape remove anything. game never hangs gobbles memory.

at test of 200 per loop every few seconds "jump" 50 mbs starting @ 50mb , ended(for me) around 300mb. thought might out running garbage collector large numbers of objects in or out hemorrhage memory if once. let program run without adding or removing objects. no memory reclaimed.

adding , removing 1 object every loop had no leak , ran on low , constant memory.

i find situation pymunk doesn't leak applying method fixes nothing. (slower adding , removing or not using add(list) , remove(list).) pymunk 1 object won't leak. 1 object @ time in game is.

i have tried darnedest find stray references or reference cycles. example shows without if complex referencing , has memory reclaiming issue.

any input appreciated?

additional info: adding , removing 1 object per frame @ 60 fps climbs memory @ around 3 mbs second. engine in separate thread till figured out wasn't problem. running synchronously still leaked.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -