[Closed] Clearing unused textures from memory?
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?
Thanks!
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!
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
(
gc()
freeSceneBitmaps()
clearUndoBuffer()
)
)
if freeMem != undefined do destroyDialog freeMem
createdialog freeMem
addRollout freeMem
Thanks Luke, that’s a handy little script, will keep it for reference in future. Cheers!