ok. i reduced my code to a minimal test (see below for the code).
you can use any model, but i used a fairly big model to show the effect best.
the code will load a model as an actor, by pressing ‘r’ the model (but not the actor) will be “thrown out” and by pressing ‘r’ again, reloaded. my intention is to have a “real” unload/reload of the model - meaning disk access when reloaded.
the program works as expected, BUT:
if you look at the output, you’ll notice that the number of vertices/normals/etc. is constantly growing as you reload the model. the working disk access indicates that the real mesh model has been removed and is not reference counted, though the numbers from ‘render’ indicate otherwise. doing that for some time will result in decreased FPS.
running task manager and observing the memory, you’ll see that memory is constantly lost while doing the unload/reload routine.
because of the seen disk access - indicitated by
:loader: Loading model models/world/world.bam
:loader: Reading ./models/world/world.bam
my assumption was that i’m doing the correct things to get the model out of memory (which really seems to work, because if i change the model in between unload/reload, i see the correct and changed model).
but then something is holding on to some memory somewhere.
btw: i tested this with my OS X build AND Panda3D 1.2.2 under Windows XP (don’t have 1.2.3 on that machine). both platforms show the same behaviour, this is not platform specific.
i might not have done all things needed to really get rid of the model - any ideas what to try?
there is some kind of leak in Panda3D or my wanted behaviour is just not supported (i would hope for an easy-to-fix leak though, reloading on-the-fly would just be awesome for my project). David, do you think it’s my faulty assumptions or anything i can do to get this right?
thanks in advance and i hope that little code-snippet helps to find a solution.
from direct.showbase.DirectObject import DirectObject
from direct.actor.Actor import Actor
ANY_MODEL = 'models/world/world.bam'
actor = Actor(ANY_MODEL)
self.loaded = True
self.loaded = False
self.loaded = True
reloader = Reloader()