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 Wantongames · May 20, 2012 at 03:35 PM · androidmobilecrashtexturesmemory

My mobile game crashes once a certain number of textures have been loaded. What can I do about that?

I am developing a mobile app, and I have a single GameObject with over 440 different textures on it. The game runs fine in the editor, but when I export to a device and attempt to run the game, the game crashes once it reaches the scene with the 440 different textures.

I guessed that Unity didn't like one object having so many texture son it, so I attempted to solve the problem by dividing the GameObject into two objects which each have 220 textures. That didn't work; the game still crashed once both were loaded.

I figured that maybe if I had the two objects in two different scenes, it would be okay. I put one 220-texture GameObject in Scene 1, and another 220-texture GameObject in Scene 2, but the game crashed when going from Scene 1 to Scene 2.

So then I wondered if maybe the game would completely unload the object from Scene 1 if there was an intermediary scene. I transitioned from Scene 1 to Scene 1.5 (blank scene) and then to Scene 2, and still got a crash.

It looks like, once I've loaded a certain number of textures, the game will simply crash. I don't know if there's a specific number that is pissing Unity off, or if I'm simply running out of memory on my device.

Either way, what is the solution to this problem? If I want the user to be able to see 440 different textures, what should I do to prevent Unity from crashing?

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
2
Best Answer

Answer by flamy · May 20, 2012 at 03:46 PM

Basically when you create a Texture2d or Texture object and link a texture to it,that means that texture will stay in memmory until the object is released. so basically you have 440 textures in the ram at the same time. if a texture is 0.5f mb (for example) you are using up 220 mb of ram + unity run times, other assets + other application, so basically you app is forced to quit. If it is iphone there is a limit for ram ur app can use. whn this is exceeded you app will be shut down automatically.

I am pretty sure at a single frame you are not going to display all 440 textures. so what you have to do is keep the textures in resources folder and in script instead of having 440 texture or texture2d objects, have 440 strings, that stores path for each texture. and when you need it call the Resources.Load() function to get the texture. and also call this function whenever you can to keep memmory in check.

Comment
Add comment · Show 6 · 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 Wantongames · May 20, 2012 at 05:20 PM 1
Share

That solution worked perfectly! Thank you so much for your answer! I'm back in business!

avatar image flamy · May 20, 2012 at 05:33 PM 0
Share

because i had the same problem some time back :)

avatar image ksiUnity · Mar 18, 2015 at 06:39 AM 0
Share

@flamy : Hey flamy, I am facing the same problem if I load so many textures using Assetbundle. How do i solve this?

avatar image ksiUnity · Mar 18, 2015 at 01:34 PM 0
Share

@flamy : Hey flamy, I am facing the same problem if I load so many textures using Assetbundle. How do i solve this?

avatar image Saddamjit_Singh · Apr 26, 2016 at 12:07 PM 0
Share

@flamy : It didn't worked for me.

I am using below code to get textures in my scene-

BGForest.GetComponent ().sprite = (Sprite)Resources.Load("Texture/$$anonymous$$apScreen/$$anonymous$$apScreenBG/$$anonymous$$ap_image1_forest2",typeof(Sprite));

and using following code to unload unused assets when new scene loads - Resources.UnloadUnusedAssets();

$$anonymous$$y game crashes after running 5-6 $$anonymous$$utes. Scenes slowly become heavy and xcode starts giving memory warnings and at end game crashes.

Any way out?

avatar image priojectx Saddamjit_Singh · Aug 26, 2016 at 11:58 AM 0
Share

Hey, i've got similar problem. Did you resolved it?

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

7 People are following this question.

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

Related Questions

Sending crash report from a iphone or android app 0 Answers

Sprite-based animation - mobile memory issue 0 Answers

Unity5 Android mip-mapping problem 1 Answer

Memory overhead when running on Android 0 Answers

NoClassDefFoundError exception when using Android plugin 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