4.6 IL2CPP Memory Crashes

With 4.6.4p1-3 I am getting a new crash - it appears to be memory allocation. I have not encountered this before, it worked fine in 4.6.3p4. It is a significant UI scene but nothing ridiculous. Everything works fine when building with Mono.

I am running on an iPad 3 (32-bit, retina) with a Universal IL2CPP build:
Also crashed with an iPad Air but the memory allocation only shows it getting to 87mb.

iPad 3:

i9981(26918,0xd2ef000) malloc: *** mach_vm_map(size=1355776) 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: 1354642B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:411 in
/Users/builduser/buildslave/unity/build/Runtime/Graphics/Texture2D.cpp
Memory overview
[ ALLOC_DEFAULT ] used: 3550210B | peak: 4241258B | reserved: 3730254B
[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_GAMEOBJECT ] used: 179270B | peak: 179270B | reserved: 224509B
[ ALLOC_GFX ] used: 4558760B | peak: 6340177B | reserved: 4559273B
[ ALLOC_PROFILER ] used: 2196B | peak: 2232B | reserved: 3355B
Could not allocate memory: System out of memory!
Trying to allocate: 1354642B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:411 in
(Filename: Line: 920)
No Texture memory available to upload
UnityEngine.UI.CoroutineTween.c__Iterator0:Reset()

iPad Air:

2015-04-20 15:57:38.683 i9981[355:47187] → registered mono modules 0x102294bd0
→ applicationDidFinishLaunching()
→ applicationDidBecomeActive()
Requesting Resolution: 2048x1536
Renderer: Apple A8X GPU
Vendor: Apple Inc.
Version: OpenGL ES 2.0 Apple A8X GPU - 53.13
GL_OES_depth_texture GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_draw_instanced GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_clip_distance GL_APPLE_color_buffer_packed_float GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_APPLE_texture_packed_float GL_IMG_read_format GL_IMG_texture_comp
ression_pvrtc
Creating OpenGLES2.0 graphics device
Initialize engine version: 4.6.4p3 (b8e48876a626)
UnloadTime: 2.055041 ms
Unloading 5 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)
Unloading 25 unused Assets to reduce memory usage. Loaded Objects now: 1225.
Total: 2.530291 ms (FindLiveObjects: 0.103958 ms CreateObjectMapping: 0.050250 ms MarkObjects: 1.148250 ms DeleteObjects: 1.034666 ms)
i9981(355,0x10caf8000) malloc: *** mach_vm_map(size=1359872) 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: 1354642B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:411 in
Memory overview
[ ALLOC_DEFAULT ] used: 3967809B | peak: 4760737B | reserved: 4155016B
[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_GAMEOBJECT ] used: 273886B | peak: 273886B | reserved: 319980B
[ ALLOC_GFX ] used: 4908206B | peak: 6814426B | reserved: 4908776B
[ ALLOC_PROFILER ] used: 4176B | peak: 4464B | reserved: 5278B
Could not allocate memory: System out of memory!
Trying to allocate: 1354642B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:411 in
(Filename: Line: 920)
i9981(355,0x10caf8000) malloc: *** mach_vm_map(size=1359872) 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: 1354642B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:411 in
Memory overview
[ ALLOC_DEFAULT ] used: 3969857B | peak: 4760737B | reserved: 4157064B
[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_GAMEOBJECT ] used: 281581B | peak: 281581B | reserved: 329005B
[ ALLOC_GFX ] used: 4450018B | peak: 6814426B | reserved: 4450474B
[ ALLOC_PROFILER ] used: 6696B | peak: 6696B | reserved: 8463B
Could not allocate memory: System out of memory!
Trying to allocate: 1354642B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:411 in
Memory overview
[ ALLOC_DEFAULT ] used: 3969857B | peak: 4760737B | reserved: 4157064B
[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_GAMEOBJECT ] used: 281581B | peak: 281581B | reserved: 329005B
[ ALLOC_GFX ] used: 4450018B | peak: 6814426B | reserved: 4450474B
[ ALLOC_PROFILER ] used: 6696B | peak: 6696B | reserved: 8463B
(Filename: Line: 920)
libc++abi.dylib: terminating with uncaught exception of type CAException

I’m not familiar with the cause of these specific crashes. Is it possible for you to submit the project with a bug report that we can use to reproduce them? That is probably our best option in this case.

I’ll see if I can. Is it common for the IL2CPP and/or 64 bit build of iOS to use more memory? The first scene with Mono shows 114MB in Instruments while IL2CPP shows 146MB.

I’m running a few more tests to see if I can watch the memory get too high. But it seems to be an instant crash rather than build up.

I removed some resources and now on the Mono build I’m at 67MB and on IL2CPP at 100MB. Still crashes on the next scene for IL2CPP only. My last ditch effort is to put a blank scene in between to make sure memory is flushed and there are no memory spikes.

We’ve not seen too many cases where IL2CPP is using more memory than Mono. However, this looks like it is clearly one. Let me know if the empty scene works.

Ok. I’m still crashing and memory doesn’t even seem to be high at all before I get System Out of Memory errors. I’m actually crashing in the first scene now only showing 46MB allocated. I’m going to try IL2CPP 32-only as well.

I’ll submit a bug shortly.

Same thing happens. It crashes the moment I start a simple animation (lerping a single sprite). “error: can’t allocate region securely”

I have the exact same problem. I tested the whole day to see if something was wrong with the textures and models but the memory impact was really low.

This problem happens since the 4.6.4 version, before was fine but unfortunately I need the 4.6.4 P3 because this version kinda solved some issues I had with T-Net.

Unity 4.6.4p3 using IL2CPP in both 64 and 32 bit. I tested on Ipad3, iPhone 6 plus and iPhone 5. Same problem.

Bug report it guys!

I’ve stripped my project down (it was huge) and I can still replicate so I’ll finally be submitting a bug here shortly.

My project is huge (over 3 gb), I already sent it for another bug report (686082)…do I need to send the project again?
Unfortunately I cannot reduce the size…I tried, no luck.

Bug Report finally went thru! Case 691216

@iguana_02

Since you have already sent your project with one bug report, there is no need to send it again. Can you file a new bug report for this issue though? Please mention that the project is the same one as in 686082. Thanks.

@eezSZI

Great, thanks for the bug report. We will investigate it.

All done, the case is 691442. Thanks a lot!

@iguana_02

Thanks for submitting this, we will investigate it.

This is still happening for me in 4.6.4p4.

It seems that we have a similar problems, I have a vague assumtion that this is somehow related to render textures.

Thanks for the updates. We will take a look at this soon.

I’m still seeing this in 4.6.5p1. Is everyone else?