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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 11 November 2010   #1
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!
 
Old 11 November 2010   #2
Did you try a GC() after the freeSceneBitmaps?
__________________
Paul Neale
http://paulneale.com
 
Old 11 November 2010   #3
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!
 
Old 11 November 2010   #4
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
					(
						gc()
						freeSceneBitmaps()
						clearUndoBuffer()
					)
			
	)
			if freeMem != undefined do destroyDialog freeMem	
			createdialog freeMem
			addRollout freeMem
__________________
Luke
Web site

3d Max 2012 Win 7
Intel Corei5 8g Ram


Last edited by lucpet : 11 November 2010 at 11:23 PM.
 
Old 11 November 2010   #5
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!
 
Old 11 November 2010   #6
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 03:52 PM.


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