Clearing unused textures from memory?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  11 November 2010
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?

  11 November 2010
Did you try a GC() after the freeSceneBitmaps?
Paul Neale
  11 November 2010
Originally Posted by PEN: Did you try a GC() after the freeSceneBitmaps?

Thanks Paul! That's the ticket!

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

Thanks again!
  11 November 2010
This will save you some time

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
Web site

3d Max 2012 Win 7
Intel Corei5 8g Ram

Last edited by lucpet : 11 November 2010 at 11:23 PM.
  11 November 2010
Originally Posted by lucpet: 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!
  11 November 2010
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 06:43 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.