Memory allocation getting out of control
Hey guys,
So I upgraded the project to Unity 5.3.2f1 in order to fix some some Shrunken related crashes. After doing this I noticed the game would crash at fairly random moments throughout the game. I then decided to run the profiler and start debugging the issue (since the crash logs appeared to indicate memory related crashes). It seems that the only significant increase in memory usage comes from the GfxDriver which consistently increases throughout the scenes (the texture memory actually drops over time, so it seems fairly unrelated).
However there seems to be little information online as to why the GfxDriver memory footprint would increase so dramatically over time / scene transitions. I’ve attached some screenshots of the profiler reports while the game is running, as well as a text log of the crash itself.
Fig 1: The profiler at the start of the game...
Fig 2: ...the profiler at the point of the crash.
bubbleshotadventures(6709,0x19f639000) malloc: *** mach_vm_map(size=4210688) 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: 4194304B with 16 alignment. MemoryLabel: GfxDevice
Allocation happend at: Line:62 in ./Runtime/Containers/WrappingRingbuffer.h
Memory overview
[ ALLOC_DEFAULT ] used: 11338843B | peak: 40808412B | reserved: 12691714B
[ ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 524288B
[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_GAMEOBJECT ] used: 3614316B | peak: 3875194B | reserved: 4128854B
[ ALLOC_GFX ] used: 119929B | peak: 378978B | reserved: 126408B
[ ALLOC_PROFILER ] used: 155446404B | peak: 155447748B | reserved: 156264525B
Could not allocate memory: System out of memory!
Trying to allocate: 4194304B with 16 alignment. MemoryLabel: GfxDevice
Allocation happend at: Line:62 in ./Runtime/Containers/WrappingRingbuffer.h
Memory overview
[ ALLOC_DEFAULT ] used: 11338843B | peak: 40808412B | reserved: 12691714B
[ ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 524288B
[ IOS new_delete ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_GAMEOBJECT ] used: 3614316B | peak: 3875194B | reserved: 4128854B
[ ALLOC_GFX ] used: 119929B | peak: 378978B | reserved: 126408B
[ ALLOC_PROFILER ] used: 155446404B | peak: 155447748B | reserved: 156264525B
(Filename: /Users/builduser/buildslave/unity/build/Runtime/Allocator/MemoryManager.cpp Line: 982)
(lldb)
Fig 3: The crash log.
Answer by floatingland · Feb 19, 2016 at 08:27 AM
I got the same problem too. I use two empty scenes to change from one to the other. As long as the scene changes,the gfxdriver size increases. Both of the two scenes just have a camera and a directional light.
On mac, gfxdriver won't increase,but on my iPad it always increases. Don't know how to solve this?
Your answer
![](https://koobas.hobune.stream/wayback/20220612063441im_/https://answers.unity.com/themes/thub/images/avi.jpg)