Textures wont get kicked out of RAM...

ok here’s the deal:

i’m using panda to display preview-images of fotos in a folder.
basically loading images with sizes like 256x256 , apply them to a geom. while browsing through the images, new textures are loaded, old geoms are removed. the only problem is, ram usage increases over time.very little for each preview-icon but it summs up over time to several hundret megabytes.

if i uncomment the “setTexture” line (while still calling loader.loadTexture) , the memory is properly cleaned up. as soon as i apply the texture it leaks. using pstats i found systemMemory->MMap->NeverFree->Active->pmap is increasing every time i load one of my preview images (even if i load the same image twice or even more often).

any way to fix this? i tried it on egg file geometry, aswell as texture on an directButton. both time the same effect. it’s about 4kB leak per picture. one picture is about 10 to 40kB in size. ~25kB average

I wrote this sample program to test this:

from direct.directbase.DirectStart import *
from pandac.PandaModules import *
import random

cm = CardMaker('cm')
cm.setFrame(-1, 1, -1, 1)
card = base.render2d.attachNewNode(cm.generate())

mapDir = getModelPath().findFile('maps')
mapFiles = mapDir.scanDirectory()

def loadTex(task):
    TexturePool.releaseAllTextures()
    filename = random.choice(mapFiles)
    tex = loader.loadTexture(Filename('maps', filename), okMissing = True)
    if not tex:
        mapFiles.remove(filename)
    else:
        card.setTexture(tex)

    return task.cont

taskMgr.add(loadTex, 'loadTex')
run()

and I found that, as reported, the “pmap” category was gradually increasing over time–but only until the geom cache filled up, and then it stopped increasing.

The geom cache is quite large by default, 5000 geoms. Setting “geom-cache-size 0” in my Config.prc file made the leak stop immediately. You could set it to some intermediate value that gives you a good compromise between performance and memory utilization.

David

“drwr achieved Gold Medal in: Providing sollutions for my tricky problems”

big thx again, if you’d had a “donate” button in your signature, i’d hit it.

I vote for donate button too. Where did RDB’s go?