Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by col000r · Oct 29, 2011 at 12:40 PM · iosiphonedestroymemoryipad

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?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jace · Oct 29, 2011 at 01:47 PM 0
Share

This may help http://answers.unity3d.com/questions/7768/memory-management-and-c-dos-and-donts.html

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by col000r · Dec 13, 2011 at 09:45 AM

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! :)

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CHPedersen · Dec 13, 2011 at 10:03 AM 0
Share

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.

avatar image vanss2 · Mar 25, 2013 at 11:11 AM 0
Share

Wow! this helped me amazingly!

i put this in the AppController in applicationDidReceive$$anonymous$$emoryWarning and used a UnitySend$$anonymous$$essage to dealloc memory, saved my app! i used a lot of textures, loaded as WWW that (strangely) never got cleared up

thank you!

avatar image chuckgustinoris vanss2 · May 03, 2017 at 08:29 AM 0
Share

i put this in the AppController in applicationDidReceive$$anonymous$$emoryWarning and used a UnitySend$$anonymous$$essage to dealloc memory, saved my app!

Dear vanss2: Please could you post your code?

 - (void)applicationDidReceive$$anonymous$$emoryWarning:(UIApplication*)application
 {
     ::printf("WARNING -> applicationDidReceive$$anonymous$$emoryWarning()\n");
     UnityLow$$anonymous$$emory();
     UnitySend$$anonymous$$essage(<#const char *obj#>, <#const char *method#>, <#const char *msg#>) // <= What exactly did you put here?
 }

Sure this is going to rescue my app, too. Thanks alot.

avatar image Xaurrien · Dec 23, 2013 at 09:09 AM 0
Share

thank you it help me a lot !

avatar image JuiceReis · Jan 22, 2014 at 01:20 PM 0
Share

Thanks, looking at xcodes memory when testing the build you can really tell a difference

avatar image
0

Answer by Jean-Fabre · Sep 04, 2012 at 08:07 AM

Hi,

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by khross · Jan 25, 2017 at 01:29 PM

Is the correct answer still valid for current version ? (5.5.0f3). Or there is a smarter GC system already implemented ?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[iOS Memory Question] At ~35MB of memory on a heavily multitasked iPhone4/iPad we are getting suspend-crashes after lowmemory warnings. Is there anything we can do? 1 Answer

IPhone 4 and IPad 2 lost audio on resume 0 Answers

What does Mprotect remapping failed mean and how do I fix it? 1 Answer

Fixing Layout issues for iPad 0 Answers

Error linker IOS / Unity - XcODE 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges