Crash when calling AssetBundle.LoadAssetAsync on iOS

unity version :Unity 2018.3.5f1

When calling AssetBundle.LoadAssetAsync
The app has crashed.

The following logs are output simultaneously.

stg(11460,0x16cba7000) malloc: *** mach_vm_map(size=18446744072233205760) 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: 18446744072233199617B with 16 alignment. MemoryLabel: String
Allocation happened at: Line:314 in ./Runtime/Core/Containers/StringStorageDefault.h
Memory overview

[ ALLOC_DEFAULT ] used: 90126734B | peak: 108762017B | reserved: 95212873B
[ ALLOC_TEMP_JOB ] used: 346613B | peak: 0B | reserved: 6029312B
[ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 262144B
[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_GAMEOBJECT ] used: 16439827B | peak: 29215711B | reserved: 17810709B
[ ALLOC_GFX ] used: 2043751B | peak: 5641811B | reserved: 2090623B
[ ALLOC_PROFILER ] used: 4775521B | peak: 4798575B | reserved: 4861081B
[ ALLOC_TEMP_THREAD ] used: 54356B | peak: 0B | reserved: 2654208B
Could not allocate memory: System out of memory!
Trying to allocate: 18446744072233199617B with 16 alignment. MemoryLabel: String
Allocation happened at: Line:314 in ./Runtime/Core/Containers/StringStorageDefault.h
Memory overview

[ ALLOC_DEFAULT ] used: 90126734B | peak: 108762017B | reserved: 95212873B
[ ALLOC_TEMP_JOB ] used: 346613B | peak: 0B | reserved: 6029312B
[ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 262144B
[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_GAMEOBJECT ] used: 16439827B | peak: 29215711B | reserved: 17810709B
[ ALLOC_GFX ] used: 2043751B | peak: 5641811B | reserved: 2090623B
[ ALLOC_PROFILER ] used: 4775521B | peak: 4798575B | reserved: 4861081B
[ ALLOC_TEMP_THREAD ] used: 54356B | peak: 0B | reserved: 2654208B

(Filename: ./Runtime/Allocator/MemoryManager.cpp Line: 1161)

It does not necessarily occur with a specific file
Basically, LoadAssetAsync succeeds.

The MemoryReports for Xcode is 300 MB.

I do not know the cause?

1 Like

All files read are less than about 1 MB.

Set malloc_error_break as a breakpoint and print callstack.

stg(11589,0x16e3f7000) malloc: *** mach_vm_map(size=18446744067197026304) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
* thread #35, name = 'UnityPreload', stop reason = breakpoint 1.1
  * frame #0: 0x0000000183ef10b0 libsystem_malloc.dylib`malloc_error_break
    frame #1: 0x0000000183eeed3c libsystem_malloc.dylib`szone_error + 240
    frame #2: 0x0000000183ef0210 libsystem_malloc.dylib`mvm_allocate_pages + 264
    frame #3: 0x0000000183ee7d98 libsystem_malloc.dylib`large_malloc + 136
    frame #4: 0x0000000183ee374c libsystem_malloc.dylib`szone_malloc_should_clear + 252
    frame #5: 0x0000000183ee35dc libsystem_malloc.dylib`malloc_zone_malloc + 160
    frame #6: 0x0000000183ee60b0 libsystem_malloc.dylib`malloc + 32
    frame #7: 0x0000000103be1a58 stg`::Allocate() at UnityDefaultAllocator.cpp:22 [opt]
    frame #8: 0x00000001032e207c stg`::Allocate() at StackAllocator.cpp:84 [opt]
    frame #9: 0x00000001032d24c0 stg`::Allocate() at MemoryManager.cpp:1295 [opt]
    frame #10: 0x00000001037f625c stg`::resize_buffer() [inlined] reallocate at dynamic_array.h:75 [opt]
    frame #11: 0x00000001037f623c stg`::resize_buffer() [inlined] reserve_impl at dynamic_array.cpp:28 [opt]
    frame #12: 0x00000001037f622c stg`::resize_buffer() at dynamic_array.cpp:12 [opt]
    frame #13: 0x0000000102fdd50c stg`::resize_initialized() [inlined] resize_buffer at dynamic_array.h:613 [opt]
    frame #14: 0x0000000102fdd4f4 stg`::resize_initialized() at dynamic_array.h:514 [opt]
    frame #15: 0x00000001031c2dd4 stg`::TransferSTLStyleArray<dynamic_array<KeyframeTpl<float>, 0> >() [inlined] ResizeSTLStyleArray at SerializeTraits.h:467 [opt]
    frame #16: 0x00000001031c2dc4 stg`::TransferSTLStyleArray<dynamic_array<KeyframeTpl<float>, 0> >() at StreamedBinaryRead.h:72 [opt]
    frame #17: 0x00000001031c2d28 stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at SerializeTraits.h:460 [opt]
    frame #18: 0x00000001031c2d1c stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<dynamic_array<KeyframeTpl<float>, 0> > at StreamedBinaryRead.h:122 [opt]
    frame #19: 0x00000001031c2d1c stg`::Transfer<StreamedBinaryRead>() at AnimationCurve.h:320 [opt]
    frame #20: 0x0000000102e89fdc stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at SerializeTraitsBase.h:54 [opt]
    frame #21: 0x0000000102e89fcc stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<AnimationCurveTpl<float> > at StreamedBinaryRead.h:122 [opt]
    frame #22: 0x0000000102e89fcc stg`::Transfer<StreamedBinaryRead>() at ParticleSystemCurves.cpp:336 [opt]
    frame #23: 0x0000000102ee86b8 stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at SerializeTraitsBase.h:54 [opt]
    frame #24: 0x0000000102ee86ac stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<MinMaxCurve> at StreamedBinaryRead.h:122 [opt]
    frame #25: 0x0000000102ee86ac stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at ParticleSystemModule.h:190 [opt]
    frame #26: 0x0000000102ee86ac stg`::Transfer<StreamedBinaryRead>() at InitialModule.cpp:565 [opt]
    frame #27: 0x0000000102e9d7f4 stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at SerializeTraitsBase.h:54 [opt]
    frame #28: 0x0000000102e9d7ec stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<InitialModule> at StreamedBinaryRead.h:122 [opt]
    frame #29: 0x0000000102e9d7ec stg`::Transfer<StreamedBinaryRead>() at ParticleSystem.cpp:1259 [opt]
    frame #30: 0x0000000102e81114 stg`::VirtualRedirectTransfer() [inlined] Transfer<StreamedBinaryRead> at SerializeTraitsBase.h:54 [opt]
    frame #31: 0x0000000102e81108 stg`::VirtualRedirectTransfer() [inlined] Transfer<ParticleSystem> at StreamedBinaryRead.h:122 [opt]
    frame #32: 0x0000000102e81108 stg`::VirtualRedirectTransfer() [inlined] TransferBase<ParticleSystem> at StreamedBinaryRead.h:111 [opt]
    frame #33: 0x0000000102e81108 stg`::VirtualRedirectTransfer() at ParticleSystem.cpp:1233 [opt]
    frame #34: 0x00000001038e9208 stg`::ReadObject() at SerializedFile.cpp:2196 [opt]
    frame #35: 0x00000001038ea488 stg`::ReadAndActivateObjectThreaded() at PersistentManager.cpp:1679 [opt]
    frame #36: 0x00000001038ea710 stg`::LoadObjectsThreaded() at PersistentManager.cpp:1751 [opt]
    frame #37: 0x00000001036a552c stg`::Perform() at LoadOperation.cpp:76 [opt]
    frame #38: 0x00000001036a7ac0 stg`::ProcessSingleOperation() at PreloadManager.cpp:277 [opt]
    frame #39: 0x00000001036a78a8 stg`::Run() at PreloadManager.cpp:335 [opt]
    frame #40: 0x00000001036a77f0 stg`::Run() at PreloadManager.cpp:181 [opt]
    frame #41: 0x0000000103747c9c stg`::RunThreadWrapper() at Thread.cpp:76 [opt]
    frame #42: 0x000000018404d220 libsystem_pthread.dylib`_pthread_body + 272
    frame #43: 0x000000018404d110 libsystem_pthread.dylib`_pthread_start + 292
    frame #44: 0x000000018404bb10 libsystem_pthread.dylib`thread_start + 4
* thread #35, name = 'UnityPreload', stop reason = breakpoint 1.1
  * frame #0: 0x0000000183ef10b0 libsystem_malloc.dylib`malloc_error_break
    frame #1: 0x0000000183eeed3c libsystem_malloc.dylib`szone_error + 240
    frame #2: 0x0000000183ef0210 libsystem_malloc.dylib`mvm_allocate_pages + 264
    frame #3: 0x0000000183ee7d98 libsystem_malloc.dylib`large_malloc + 136
    frame #4: 0x0000000183ee374c libsystem_malloc.dylib`szone_malloc_should_clear + 252
    frame #5: 0x0000000183ee35dc libsystem_malloc.dylib`malloc_zone_malloc + 160
    frame #6: 0x0000000183ee60b0 libsystem_malloc.dylib`malloc + 32
    frame #7: 0x0000000103be1a58 stg`::Allocate() at UnityDefaultAllocator.cpp:22 [opt]
    frame #8: 0x00000001032d2638 stg`::Allocate() at MemoryManager.cpp:1324 [opt]
    frame #9: 0x00000001032d26e4 stg`::Allocate() at MemoryManager.cpp:1309 [opt]
    frame #10: 0x00000001037f625c stg`::resize_buffer() [inlined] reallocate at dynamic_array.h:75 [opt]
    frame #11: 0x00000001037f623c stg`::resize_buffer() [inlined] reserve_impl at dynamic_array.cpp:28 [opt]
    frame #12: 0x00000001037f622c stg`::resize_buffer() at dynamic_array.cpp:12 [opt]
    frame #13: 0x0000000102fdd50c stg`::resize_initialized() [inlined] resize_buffer at dynamic_array.h:613 [opt]
    frame #14: 0x0000000102fdd4f4 stg`::resize_initialized() at dynamic_array.h:514 [opt]
    frame #15: 0x00000001031c2dd4 stg`::TransferSTLStyleArray<dynamic_array<KeyframeTpl<float>, 0> >() [inlined] ResizeSTLStyleArray at SerializeTraits.h:467 [opt]
    frame #16: 0x00000001031c2dc4 stg`::TransferSTLStyleArray<dynamic_array<KeyframeTpl<float>, 0> >() at StreamedBinaryRead.h:72 [opt]
    frame #17: 0x00000001031c2d28 stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at SerializeTraits.h:460 [opt]
    frame #18: 0x00000001031c2d1c stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<dynamic_array<KeyframeTpl<float>, 0> > at StreamedBinaryRead.h:122 [opt]
    frame #19: 0x00000001031c2d1c stg`::Transfer<StreamedBinaryRead>() at AnimationCurve.h:320 [opt]
    frame #20: 0x0000000102e89fdc stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at SerializeTraitsBase.h:54 [opt]
    frame #21: 0x0000000102e89fcc stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<AnimationCurveTpl<float> > at StreamedBinaryRead.h:122 [opt]
    frame #22: 0x0000000102e89fcc stg`::Transfer<StreamedBinaryRead>() at ParticleSystemCurves.cpp:336 [opt]
    frame #23: 0x0000000102ee86b8 stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at SerializeTraitsBase.h:54 [opt]
    frame #24: 0x0000000102ee86ac stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<MinMaxCurve> at StreamedBinaryRead.h:122 [opt]
    frame #25: 0x0000000102ee86ac stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at ParticleSystemModule.h:190 [opt]
    frame #26: 0x0000000102ee86ac stg`::Transfer<StreamedBinaryRead>() at InitialModule.cpp:565 [opt]
    frame #27: 0x0000000102e9d7f4 stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<StreamedBinaryRead> at SerializeTraitsBase.h:54 [opt]
    frame #28: 0x0000000102e9d7ec stg`::Transfer<StreamedBinaryRead>() [inlined] Transfer<InitialModule> at StreamedBinaryRead.h:122 [opt]
    frame #29: 0x0000000102e9d7ec stg`::Transfer<StreamedBinaryRead>() at ParticleSystem.cpp:1259 [opt]
    frame #30: 0x0000000102e81114 stg`::VirtualRedirectTransfer() [inlined] Transfer<StreamedBinaryRead> at SerializeTraitsBase.h:54 [opt]
    frame #31: 0x0000000102e81108 stg`::VirtualRedirectTransfer() [inlined] Transfer<ParticleSystem> at StreamedBinaryRead.h:122 [opt]
    frame #32: 0x0000000102e81108 stg`::VirtualRedirectTransfer() [inlined] TransferBase<ParticleSystem> at StreamedBinaryRead.h:111 [opt]
    frame #33: 0x0000000102e81108 stg`::VirtualRedirectTransfer() at ParticleSystem.cpp:1233 [opt]
    frame #34: 0x00000001038e9208 stg`::ReadObject() at SerializedFile.cpp:2196 [opt]
    frame #35: 0x00000001038ea488 stg`::ReadAndActivateObjectThreaded() at PersistentManager.cpp:1679 [opt]
    frame #36: 0x00000001038ea710 stg`::LoadObjectsThreaded() at PersistentManager.cpp:1751 [opt]
    frame #37: 0x00000001036a552c stg`::Perform() at LoadOperation.cpp:76 [opt]
    frame #38: 0x00000001036a7ac0 stg`::ProcessSingleOperation() at PreloadManager.cpp:277 [opt]
    frame #39: 0x00000001036a78a8 stg`::Run() at PreloadManager.cpp:335 [opt]
    frame #40: 0x00000001036a77f0 stg`::Run() at PreloadManager.cpp:181 [opt]
    frame #41: 0x0000000103747c9c stg`::RunThreadWrapper() at Thread.cpp:76 [opt]
    frame #42: 0x000000018404d220 libsystem_pthread.dylib`_pthread_body + 272
    frame #43: 0x000000018404d110 libsystem_pthread.dylib`_pthread_start + 292
    frame #44: 0x000000018404bb10 libsystem_pthread.dylib`thread_start + 4
stg(11589,0x16e3f7000) malloc: *** mach_vm_map(size=18446744067197026304) 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: 18446744067197016020B with 16 alignment. MemoryLabel: TempOverflow
Allocation happened at: Line:75 in ./Runtime/Utilities/dynamic_array.h
Memory overview

A bug reporting issue has been added.

1 Like

out project
Assetbundle.LoadAsset

compression lz4

Basically, LoadAsset succeeds too
unity 2018.3.11

Could not allocate memory: System out of memory! Trying to allocate: 278678074B with 16 alignment. MemoryLabel: String Allocation happened at: Line:314 in Memory overview [ ALLOC_DEFAULT ] used: 64365387B | peak: 69106550B | reserved: 66501690B [ ALLOC_TEMP_JOB ] used: 1598113B | peak: 0B | reserved: 3145728B [ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 1048576B [ ALLOC_GAMEOBJECT ] used: 10631377B | peak: 12754289B | reserved: 11809187B [ ALLOC_GFX ] used: 5122162B | peak: 7509004B | reserved: 5184596B [ ALLOC_TEMP_THREAD ] used: 96352B | peak: 0B | reserved: 3833856B Could not allocate memory: System out of memory! Trying to allocate: 278678074B with 16 alignment. MemoryLabel: String Allocation happened at: Line:314 in Memory overview [ ALLOC_DEFAULT ] used: 64365387B | peak: 69106550B | reserved: 66501690B [ ALLOC_TEMP_JOB ] used: 1598113B | peak: 0B | reserved: 3145728B [ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 1048576B [ ALLOC_GAMEOBJECT ] used: 10631377B | peak: 12754289B | reserved: 11809187B [ ALLOC_GFX ] used: 5122162B | peak: 7509004B | reserved: 5184596B [ ALLOC_TEMP_THREAD ] used: 96352B | peak: 0B | reserved: 3833856B

not repaired
look at this
https://zhuanlan.zhihu.com/p/59394832

If the error still occurs in Unity 2018.4 LTS or newer, please submit a bug-report as described in this document:

The forum is not the place where Unity Technologies is looking for bug-reports.

It’s important that you report these issues together with a reproduction project if you want them to get fixed. If you don’t do it, it might be a long time until someone else reports them or until Unity Technologies find them.

After you submitted the bug-report, you receive a confirmation email with a bug-report Case number. You can post the Case number (number only, not the link) in this forum thread for Unity staff to pick up, in case they see it.

Yup, happening to me too. But not every time I try to load from the (same) bundle, but “randomly” (I am sure it is not random at all, I just don’t see the pattern yet).

I believe this bug has been fixed. Please, check the release notes and upgrade. The fix is very recent, so I’m not sure all supported versions with this fix has been released already, but they will be soon.

Hi Aurimas, do you think 2018.4.1 LTS will have it when it comes out? This crash + related ( async LZ4 assetbundle ) is very high in our product out in the wild… thnx

I am experiencing this in Unity 2017.4.26 LTS
Is it going to be fixed in 2017 LTS?

It seems that this bug has been fixed in 2018.4.1.

When will you fix it on 2019.2.x. I have problem on 2019.2.17. Thanks

I have problem on 2019.2.0f1, and by the way, do you use lz4 compression?
And i use a offset(36) to load assetbundle, can this be a problem? byte alignment?
As i known, lz4’s memcpy is different.

For me Unity localization caused the issue (this I mean) Localization Package: Release Announcements and Notes

I removed the localization (v 0.7.1) and now the project works

Still happens on 2019.3.10f1. Unity as a library.
Is there any workaround this error?

ProductName(10904,0x16f4db000) malloc: can’t allocate region

:*** mach_vm_map(size=28993716224, flags: 100) failed (error code=3)

ProductName(10904,0x16f4db000) malloc: *** set a breakpoint in malloc_error_break to debug

Could not allocate memory: System out of memory!

Trying to allocate: 28993713616B with 16 alignment. MemoryLabel: DynamicArray

Allocation happened at: Line:78 in

Memory overview

[ ALLOC_TEMP_THREAD ] used: 62286B | peak: 0B | reserved: 3571712B

[ ALLOC_TEMP_JOB_1_FRAME ] used: 0B | peak: 0B | reserved: 8388608B

[ ALLOC_TEMP_JOB_2_FRAMES ] used: 0B | peak: 0B | reserved: 1048576B

[ ALLOC_TEMP_JOB_4_FRAMES ] used: 0B | peak: 0B | reserved: 3145728B

[ ALLOC_TEMP_JOB_ASYNC ] used: 66664635B | peak: 0B | reserved: 80740352B

[ ALLOC_DEFAULT ] used: 79857800B | peak: 111326436B | reserved: 81788213B

[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B

[ ALLOC_GAMEOBJECT ] used: 3451293B | peak: 3451293B | reserved: 3725706B

[ ALLOC_GFX ] used: 41937675B | peak: 41937675B | reserved: 41944667B

Could not allocate memory: System out of memory!

Trying to allocate: 28993713616B with 16 alignment. MemoryLabel: DynamicArray

Allocation happened at: Line:78 in

Memory overview

[ ALLOC_TEMP_THREAD ] used: 62286B | peak: 0B | reserved: 3571712B

[ ALLOC_TEMP_JOB_1_FRAME ] used: 0B | peak: 0B | reserved: 8388608B

[ ALLOC_TEMP_JOB_2_FRAMES ] used: 0B | peak: 0B | reserved: 1048576B

[ ALLOC_TEMP_JOB_4_FRAMES ] used: 0B | peak: 0B | reserved: 3145728B

[ ALLOC_TEMP_JOB_ASYNC ] used: 66664635B | peak: 0B | reserved: 80740352B

[ ALLOC_DEFAULT ] used: 79857800B | peak: 111326436B | reserved: 81788213B

[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B

[ ALLOC_GAMEOBJECT ] used: 3451293B | peak: 3451293B | reserved: 3725706B

[ ALLOC_GFX ] used: 41937675B | peak: 41937675B | reserved: 41944667B

(Filename: Line: 1449)

@Aurimas-Cernius I think I have the same crash but on Android. Unity 2020.3.44.

Stacktrace:

Crashed: Thread #1
SIGSEGV 0x0000000000000009
0
libunity.so
AtomicStack::Pop()
1
libunity.so
__ashldi3
2
libunity.so
DualThreadAllocator<DynamicHeapAllocator>::Allocate(unsigned int, int)
3
libunity.so
__ashldi3
4
libunity.so
MemoryManager::Allocate(unsigned int, unsigned int, MemLabelId, AllocateOptions, char const*, int)
5
libunity.so
__ashldi3
6
libunity.so
__ashldi3
7
libunity.so
__ashldi3
8
libunity.so
malloc_internal(unsigned int, unsigned int, MemLabelId, AllocateOptions, char const*, int)
9
libunity.so
__ashldi3
10
libunity.so
__ashldi3
11
libunity.so
__ashldi3
12
(Missing)
13
libunity.so
LocalLowLevelAllocator::ReserveMemoryBlock(unsigned int)
14
libunity.so
__ashldi3
15
libunity.so
__ashldi3
16
libunity.so
__ashldi3
17
libunity.so
__ashldi3
18
libunity.so
TLSAllocator::GetNewBlock(unsigned int, unsigned int*, unsigned int*)
19
libunity.so
__ashldi3
20
libunity.so
__ashldi3
21
libunity.so
TLSAllocator::ThreadInitialize(unsigned int)
22
libunity.so
__ashldi3
23
libunity.so
CurrentThread::IsMainThread()
24
libunity.so
__ashldi3
25
libunity.so
__ashldi3
26
libunity.so
Thread::RunThreadWrapper(void*)
27
(Missing)
28
(Missing)
29
(Missing)
30
(Missing)