View Full Version : Clearing unused textures from memory?

11-26-2010, 09:33 AM
Howdy all!

I'm writing a tool for creating billboarded trees, and am running into an issue with memory usage when generating the materials.

I'm generating a new material every time the user confirms a property change, and assigning it to the selected objects of supported type. I'm noticing the memory usage goes up each time. This makes sense, since it's loading the textures each time. I've been trying to find a way to clear / remove a texture from memory but haven't had any luck.

I found freeSceneBitmaps() which sounded like what I wanted, but doesn't appear to help. Any suggestions?


11-26-2010, 12:19 PM
Did you try a GC() after the freeSceneBitmaps?

11-26-2010, 01:09 PM
Did you try a GC() after the freeSceneBitmaps?
Thanks Paul! That's the ticket! :applause:

I never knew there was a way to manually invoke garbage collection, sure to be very handy in other areas!

Thanks again!

11-26-2010, 11:20 PM
I hope this helps, I had need of it a while ago.

Rollout freeMem "FreeMem"
button gColl "Garbage Collection" toolTip:"Press this button to Free up Memory."
button fScen "Free Scene Bitmaps" toolTip:"Press this button to Free up scene bitmaps."
button cUndo "Clear Undo Buffer" toolTip:"Press this button to clear the undo buffer."
button doAll "Run all three at once" toolTip:"Press this button to run all of the above three buttons."

on gColl pressed do (gc())
on fScen pressed do (freeSceneBitmaps())
on cUndo pressed do (clearUndoBuffer())
on doAll pressed do

if freeMem != undefined do destroyDialog freeMem
createdialog freeMem
addRollout freeMem

11-27-2010, 03:24 AM
I hope this helps, I had need of it a while ago.
Thanks Luke, that's a handy little script, will keep it for reference in future. Cheers!

CGTalk Moderation
11-27-2010, 03:24 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.