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
0
Question by MMcDonald · Jun 03, 2015 at 11:44 AM · ioscrashmemoryil2cpp64-bit

Out of memory errors on iOS with 64-bit build

We have an iOS/Android app that we've created using Unity3D (5.0.2). It is a 2D app that downloads and displays fairly large images from our servers. We are currently in the process of creating a 64-bit build to be in compliance with Apple's new standards for iOS apps (previously we were using 32-bit builds). We've worked through several issues with converting the project over to 64-bit, but we're having trouble with an out of memory error on iPhones/iPads when loading images into 2DTexture objects. However, XCode reports that the project is using between 89-100MB of memory with 150MB free. As we navigate our app, we are not noticing any memory leaks, but it will eventually crash with the out of memory error even though we have added try-catch blocks around the line that is crashing. Here is the code we use to load images from the disk, it crashes on line 9:

 if (File.Exists(DataStorage.Instance._persistantImageFilePath + "/" + fileName))
 {
     myTextByte = File.ReadAllBytes(DataStorage.Instance._persistantImageFilePath + "/" + fileName);
 }
 
 if (myTextByte != null)
 {
     Texture2D myText = new Texture2D(0, 0, TextureFormat.RGB24, false);
     myText.LoadImage(myTextByte); //Out of memory exception here
     return myText;
 }

From the console log:

Unloading 3 unused Assets to reduce memory usage. Loaded Objects now: 1710. Total: 3.629958 ms (FindLiveObjects: 0.192500 ms CreateObjectMapping: 0.084916 ms MarkObjects: 3.307000 ms DeleteObjects: 0.044291 ms)
Game(1544,0x3a71d9dc) malloc:
mach_vm_map(size=2859008) failed (error code=3) error: can't allocate region set a breakpoint in malloc_error_break to debug Could not allocate memory: System out of memory! Trying to allocate: 2856948B with 16 alignment. MemoryLabel: Texture Allocation happend at: Line:370 in Memory overview [ ALLOC_DEFAULT ] used: 11820805B | peak: 15785886B | reserved: 11969898B [ ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 524288B [ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B [ ALLOC_GAMEOBJECT ] used: 373061B | peak: 673157B | reserved: 415279B [ ALLOC_GFX ] used: 8291748B | peak: 17886824B | reserved: 8292774B [ ALLOC_PROFILER ] used: 0B | peak: 0B | reserved: 0B Could not allocate memory: System out of memory! Trying to allocate: 2856948B with 16 alignment. MemoryLabel: Texture Allocation happend at: Line:370 in Memory overview [ ALLOC_DEFAULT ] used: 11820805B | peak: 15785886B | reserved: 11969898B [ ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 524288B [ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B [ ALLOC_GAMEOBJECT ] used: 373061B | peak: 673157B | reserved: 415279B [ ALLOC_GFX ] used: 8291748B | peak: 17886824B | reserved: 8292774B [ ALLOC_PROFILER ] used: 0B | peak: 0B | reserved: 0B
System.Collections.Generic.Enumerator:get_Current() UnityEngine.Texture2D:LoadImage(Byte[]) ImageManager:ReturnTextureFromDisk(String) BackgroundManager:GetBackground(Prize) Scroller:SetBackgroundImage(Prize, GameObject) Scroller:switchAndAnimateBackground(direction, Prize) Scroller:SwitchPrize(direction) Scroller:AnimateAndSwitchPrize() Scroller:CheckToSeeIfPrizeShouldSwitch() Scroller:OnEndDrag(PointerEventData) Assets.Code.Utilities.parentDrag:Invoke(PointerEventData) TapMeterMilestonMarker:DoneShrinking() Assets.Code.Utilities.DragClickHelper:OnEndDrag(BaseEventData) :.ctor() NativeXMiniJSON.Serializer:SerializeOther(Object) :.ctor() :.ctor() UnityEngine.Events.InvokableCallList:Invoke(Object[]) UnityEngine.Events.UnityEventBase:Invoke(Object[]) :.ctor() UnityEngine.EventSystems.EventTrigger:Execute(EventTriggerType, BaseEventData) UnityEngine.EventSystems.EventTrigger:OnEndDrag(PointerEventData) UnityEngine.UI.ContentSizeFitter:SetLayoutVertical() UnityEngine.EventSystems.ExecuteEvents:Execute(IEndDragHandler, BaseEventData) :.ctor() System.Array:InternalArray__IEnumerable_GetEnumerator() UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) UnityEngine.EventSystems.TouchInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean) UnityEngine.EventSystems.TouchInputModule:ProcessTouchEvents() UnityEngine.EventSystems.TouchInputModule:Process() NativeXMiniJSON.Serializer:SerializeOther(Object) UnityEngine.EventSystems.EventSystem:Update() System.Collections.Generic.Enumerator:get_Current()
*

We've also have occasionally seen it crash when loading with the following console log:

Game(1662,0x4b426000) malloc: mach_vm_map(size=1048576) failed (error code=3) error: can't allocate region set a breakpoint in malloc_error_break to debug 2015-06-02 14:24:51.437 Game[1662:772823] Uncaught exception: NSMallocException: Attempt to allocate 1048576 bytes for NS/CFData failed [ "0
CoreFoundation
0x2973b007 + 150", "1
libobjc.A.dylib
0x37af8c8b objc_exception_throw + 38", "2 Foundation
0x2a4677e1 _NSErrnoMessage + 0", "3 CoreFoundation
0x296e6adb + 98", "4
CoreFoundation
0x296e6c47 + 322", "5
CoreFoundation
0x2964c543 CFDataReplaceBytes + 266", "6 CoreFoundation
0x2965aa35 CFDataAppendBytes + 116",
"7 CFNetwork
0x2918ebf3 + 158", "8
CFNetwork
0x2922e0d5 + 60", "9
CFNetwork
0x29270cb7 + 14", "10 libdispatch.dylib
0x0697f173 _dispatch_call_block_and_release + 10", "11 libdispatch.dylib
0x06987d67 _dispatch_queue_drain + 1718", "12 libdispatch.dylib
0x06981a61 _dispatch_queue_invoke + 88", "13 libdispatch.dylib
0x06989b09 _dispatch_root_queue_drain + 1308", "14 libdispatch.dylib 0x0698ae19 _dispatch_worker_thread3 + 100", "15 libsystem_pthread.dylib
0x381cadc1 _pthread_wqthread + 668",
"16 libsystem_pthread.dylib
0x381cab14 start_wqthread + 8" ] 2015-06-02 14:24:51.442 Game[1662:772823]
Terminating app due to uncaught exception 'NSMallocException', reason: 'Attempt to allocate 1048576 bytes for NS/CFData failed' First throw call stack: (0x2973afef 0x37af8c8b 0x2a4677e1 0x296e6adb 0x296e6c47 0x2964c543 0x2965aa35 0x2918ebf3 0x2922e0d5 0x29270cb7 0x697f173 0x6987d67 0x6981a61 0x6989b09 0x698ae19 0x381cadc1 0x381cab14) libc++abi.dylib: terminating with uncaught exception of type NSException*

Comment
Add comment · Show 3
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 JoshPeterson · Jun 03, 2015 at 02:15 PM 0
Share

The IL2CPP scripting backend does use more memory than the $$anonymous$$ono scripting backend, so if you were close with $$anonymous$$ono, you may be over the limit with IL2CPP. We're working to bring the IL2CPP memory usage in line with $$anonymous$$ono. Try 5.0.2p4 for our first step in the right direction. We will have more improvements co$$anonymous$$g though.

avatar image MMcDonald · Jun 03, 2015 at 04:12 PM 0
Share

Where do I get 5.0.2p4? The released version is 5.0.2f and the beta version is 5.1.0f2. I looked at past betas, but they're all 5.1.x. Can't seem to find 5.0.2p4.

avatar image JoshPeterson · Jun 03, 2015 at 05:21 PM 0
Share

You can find it here: http://unity3d.com/unity/qa/patch-releases

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Malek-Bakeer · Jun 04, 2015 at 07:25 AM

Try reducing the image size in inspector to 512 or 1024

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

some iOS devices took more memory about 200%!! 1 Answer

iOS Memory Handling Crash on Startup 0 Answers

IL2CPP Dictionary deserialization issue 3 Answers

Unity 5 AudioMixer nullreference on iOS using IL2CPP 1 Answer

unexpected massive memory allocation on iOS while loading maps 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