Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Carappene · Oct 04, 2018 at 07:45 PM · iosmobileoptimizationxcodememory management

Maximum RAM memory exceeded causes app to crash in iOS

Hello, I'm developing an app in which you have to download 40-60 photos, and that causes the app to die.

The "WARNING -> applicationdidreceivememorywarning()" message appears in the XCode logs, and then the app dies.

To give some context on what the images are used for: I have those images Firebase Storage service, downloaded with UnityWebRequestTexture, and then assigning that Texture2D to a RawImage's Texture. The images are photos, not "game textures".

I have read about Texture compression, NPOT/POT things, etc. But can I do anything about Textures that are downloaded from the Internet? Or only with the ones that already exist in the project?

MUCH thanks!

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 Casiell · Oct 04, 2018 at 09:26 PM 1
Share

Do you really need to display them all at once? You could cache them all and only load and display those that are currently needed.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by tessellation · Oct 04, 2018 at 09:40 PM

Do what Casiell says, but you can also download the images (JPG is the smallest) from the server as a byte array (raw JPG data) and then create a Texture2D from the stored JPG data only when the image is on-screen. Use ImageConversion.LoadImage() to make the Texture2D when you need to display it. Don't forget to null the RawImage texture property when the RawImage goes off-screen and also call Destroy on the Texture2D.

Comment
Add comment · Show 2 · 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 unpuzzlebarcelona · Oct 05, 2018 at 10:37 AM 0
Share

First of all, thank you for your time, @tessellation and @Casiell. The total of images goes between 30-90, depending on how many that group of user have taken. Good news is I don't need to show them all at once, maximum shown at the same time are 10. I'm kinda new to program$$anonymous$$g, so forgive me but how do I exactly "cache" the Textures? Cacheing means saving it to device storage? Or having a Texture2D [] with all the Textures, and assigning/nulling the RawImage's Texture field?

On regards of what you say, @tessellation, the way I currently create the Textures is this:

The images are in .jpg in the cloud, but I recieve a byte array, that gets converted to a Texture this way and then assigned to the RawImage:

Texture2D tex = new Texture2D (1, 1); tex.LoadImage (bytes); rawImage.texture = tex;

I guess doing tex.LoadImage () should be the same as doing ImageConversion.LoadImage ().

I will null the RawImage's texture and Destroy the created Texture2D as you say.

The only thing I am concerned about is how do I cache the Textures, as I said before, since I don't really know what that exactly means.

Also I've read about UnloadAsset/UnloadUnusedAssets, but I'm not sure if this would help or if it would throw away Textures I still need.

$$anonymous$$UCH thanks to you both <3

avatar image tessellation unpuzzlebarcelona · Oct 05, 2018 at 04:09 PM 0
Share

Correct, tex.LoadImage(bytes) is just the old way of doing it. Unity changed the API recently. "cache" just means to store something temporarily, in this case I mean for you to keep all 90 raw byte arrays in memory for each texture after downloading from the server. They will take far less space in memory than the full uncompressed Texture2D, which you really only need 10. Also, depending on the size of how they are displayed on the screen, you could down-sample the texture after calling tex.LoadImage() to a smaller size to take even less memory. You can use a high-quality scaler, like this one: http://wiki.unity3d.com/index.php/TextureScale

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

173 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to improve FPS on mobile? 1 Answer

Why did my render time increase after lowering the vertex count? 2 Answers

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

Why does my accelerometer not work in test mode? Side Q why can I not open my Xcode app on my phone? 0 Answers

How to solve Xcode Apple Mach-O Linker (Id) Error 0 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