• 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
0
Question by Alexander Miller · Mar 31, 2011 at 04:40 AM · iphonememoryassetdatabase

iPhone Memory Warning

Is there any way for me to detect when I receive Memory Warnings from the OS and free memory accordingly?

I have some large dictionaries that I need to read from. There are 4 of them, I only need to do a lookup on them sporadically, and they eat up a lot of memory, but I can't seem to find a way to load and eject them from memory as needed. This means that I end up needing to always keep all 4 in memory, and if the iPhone has been running for awhile and is using up a fair chunk of its memory, the OS will kill my app because of these dictionaries.

I've tried setting all their references to null right after I use them, but this doesn't seem to free them very quickly, and puts me in trouble if I need to use the same one twice in a row (it gets allocated twice). Do I need to set their references to null and then call for a gc sweep right away? Ideally I'd like to be able to avoid doing this unless I'm receiving memory warnings.

Thanks for any help.

Comment
Add comment
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

1 Reply

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

Answer by Jean-Fabre · Mar 31, 2011 at 05:25 AM

Hi,

One possible way would be to create and store your dictionnaries in xcode and build an interface to it. Within xCode, you'll get likely more accurate control over memory management. There is an example in the [resource section][2] regards interfacing

I had lots of trouble with this as well, but it was for normal content like gameobjects and textures, I could not free anything properly unless I loaded scenes in a very special way. Look at this answer for reference it might hold some kind of answer useful for to you.

Sorry I can't provide you with a more specific solution to your problem. Hopefully an expert will step in and describe how to properly release stuff for the Garbage Collector to do its work.

Bye,

Jean

[2]: http://unity3d.com/support/resources/example-projects/iphone-examples look for the nativecode example

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Application.LoadLevel() doesn't unload current scene? 0 Answers

set minimum texture resolution? 2 Answers

Unity-iphone has exited with status 10 1 Answer

[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 loading strategies ? 1 Answer


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