x


How do I destroy things properly to free up memory? (iOS)

I'm loading AudioClips and Texture2D from Resources a lot.

Do I need to Destroy() them when I no longer need them? Is it the same thing to set the variable holding them to null?

Or how do I make sure everything is destroyed when I no longer need it?

more ▼

asked Oct 29 '11 at 12:40 PM

col000r gravatar image

col000r
127 6 6 13

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

And the correct answer is: You need to call Resources.UnloadUnusedAssets() or assets loaded from resources will stay in memory FOREVER! There should really be a huge red warning-box on all the documentation-pages about Resources stating this! :)

more ▼

answered Dec 13 '11 at 09:45 AM

col000r gravatar image

col000r
127 6 6 13

I absolutely agree. I had to be told by Unity's support staff about this in a reply to a bug report before I got it. Unity's memory management is really something that needs to be documented better.

Dec 13 '11 at 10:03 AM CHPedersen

Wow! this helped me amazingly!

i put this in the AppController in applicationDidReceiveMemoryWarning and used a UnitySendMessage to dealloc memory, saved my app! i used a lot of textures, loaded as WWW that (strangely) never got cleared up

thank you!

Mar 25 at 11:11 AM vanss2
(comments are locked)
10|3000 characters needed characters left

Hi,

Check this Answer because Resources.UnloadUnusedAssets() wasn't really doing the job for me on level loading.

more ▼

answered Sep 04 '12 at 08:07 AM

Jean Fabre gravatar image

Jean Fabre
3.1k 69 76 103

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2028
x2014
x785
x367
x344

asked: Oct 29 '11 at 12:40 PM

Seen: 2977 times

Last Updated: Mar 25 at 11:15 AM