Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by NGC6543 · Nov 30, 2017 at 08:45 AM · memory-leakmemory leakmac mini

How to pin-point memory leak?

Hi, I'm having a memory leak issue and need help! My game is a single scene game and it load itself once the level is ended. On editor and iMac it has no problem. On Android (Shield TV) it has no problem.

On Mac Mini however, it crashes after reloading the scene about ~40 times. And Weird thing is, the screen(Camera) is corrupted, but the game runs as expected behind the 'crashed' screen. UIs that are set to ScreenSpace-Overlay is drawn correctly. Other screen area where Unity camera draws are corrupted and turn into something like 'normal map texture'(rgb gradation). And Unity doesn't throw any Error/warning or whatever.

Since the game is running behind, game can be played 'blind'. So after finishing levels and reloading 4~7 times, then the Unity Crashes, flushing logs below :

 Candy Planet_1.5.7_171129_RELEASE(2037,0xa537c1c0) malloc: *** mach_vm_map(size=8392704) failed (error code=3)
 *** error: can't allocate region
 *** set a breakpoint in malloc_error_break to debug
 DynamicHeapAllocator allocation probe 1 failed - Could not get memory for large allocation 8388608.
 Candy Planet_1.5.7_171129_RELEASE(2037,0xa537c1c0) malloc: *** mach_vm_map(size=8392704) failed (error code=3)
 *** error: can't allocate region
 *** set a breakpoint in malloc_error_break to debug
 DynamicHeapAllocator allocation probe 2 failed - Could not get memory for large allocation 8388608.
 Candy Planet_1.5.7_171129_RELEASE(2037,0xa537c1c0) malloc: *** mach_vm_map(size=8392704) failed (error code=3)
 *** error: can't allocate region
 *** set a breakpoint in malloc_error_break to debug
 DynamicHeapAllocator allocation probe 3 failed - Could not get memory for large allocation 8388608.
 Candy Planet_1.5.7_171129_RELEASE(2037,0xa537c1c0) malloc: *** mach_vm_map(size=8392704) failed (error code=3)
 *** error: can't allocate region
 *** set a breakpoint in malloc_error_break to debug
 DynamicHeapAllocator allocation probe 4 failed - Could not get memory for large allocation 8388608.
 Candy Planet_1.5.7_171129_RELEASE(2037,0xa537c1c0) malloc: *** mach_vm_map(size=8392704) failed (error code=3)
 *** error: can't allocate region
 *** set a breakpoint in malloc_error_break to debug
 DynamicHeapAllocator out of memory - Could not get memory for large allocation 8388608!
 Could not allocate memory: System out of memory!
 Trying to allocate: 8388608B with 16 alignment. MemoryLabel: Physics
 Allocation happend at: Line:173 in /Users/builduser/buildslave/unity/build/Runtime/Dynamics/PhysicsManager.cpp
 Memory overview
 
 [ ALLOC_DEFAULT ] used: 107527712B | peak: 0B | reserved: 122249024B 
 [ ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 12582912B 
 [ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 1048576B 
 [ ALLOC_GFX ] used: 4177960B | peak: 0B | reserved: 7340032B 
 [ ALLOC_CACHEOBJECTS ] used: 105126984B | peak: 0B | reserved: 113746476B 
 [ ALLOC_TYPETREE ] used: 0B | peak: 0B | reserved: 0B 
 [ ALLOC_PROFILER ] used: 4105940B | peak: 0B | reserved: 8388608B 
 [ ALLOC_TEMP_THREAD ] used: 51920B | peak: 0B | reserved: 3440640B 
 Could not allocate memory: System out of memory!
 Trying to allocate: 8388608B with 16 alignment. MemoryLabel: Physics
 Allocation happend at: Line:173 in /Users/builduser/buildslave/unity/build/Runtime/Dynamics/PhysicsManager.cpp
 Memory overview
 
 [ ALLOC_DEFAULT ] used: 107527712B | peak: 0B | reserved: 122249024B 
 [ ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 12582912B 
 [ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 1048576B 
 [ ALLOC_GFX ] used: 4177960B | peak: 0B | reserved: 7340032B 
 [ ALLOC_CACHEOBJECTS ] used: 105126984B | peak: 0B | reserved: 113746476B 
 [ ALLOC_TYPETREE ] used: 0B | peak: 0B | reserved: 0B 
 [ ALLOC_PROFILER ] used: 4105940B | peak: 0B | reserved: 8388608B 
 [ ALLOC_TEMP_THREAD ] used: 51920B | peak: 0B | reserved: 3440640B 
 
  
 (Filename: /Users/builduser/buildslave/unity/build/Runtime/Allocator/MemoryManager.cpp Line: 1053)
 
 Receiving unhandled NULL exception
 Obtained 35 stack frames.
 #0  0x00000000440816 in DualThreadAllocator<DynamicHeapAllocator<LowLevelAllocator> >::GetRequestedPtrSize(void const*) const
 #1  0x000000004518b2 in MemoryManager::RegisterAllocation(void*, unsigned long, MemLabelId const&, char const*, char const*, int)
 #2  0x0000000044eff7 in MemoryManager::Allocate(unsigned long, unsigned long, MemLabelId const&, AllocateOptions, char const*, int)
 #3  0x0000000044e565 in malloc_internal(unsigned long, unsigned long, MemLabelId const&, AllocateOptions, char const*, int)
 #4  0x00000000c95683 in NovodexAllocator::allocate(unsigned long, char const*, char const*, int)
 #5  0x00000001a17549 in physx::shdfnd::Foundation::AlignCheckAllocator::allocate(unsigned long, char const*, char const*, int)
 #6  0x00000001a168cf in physx::shdfnd::Allocator::allocate(unsigned long, char const*, int)
 #7  0x000000018a27ff in physx::PxsAABBManager::setDynamicAABBData(unsigned int, physx::PxcAABBDataDynamic const&)
 #8  0x000000018837bf in physx::Sc::ShapeSim::onGeometryChange()
 #9  0x00000001865808 in physx::Sc::RigidCore::onShapeChange(physx::Sc::ShapeCore&, physx::PxFlags<physx::Sc::ShapeChangeNotifyFlag::Enum, unsigned int>, physx::PxFlags<physx::PxShapeFlag::Enum, unsigned char>)
 #10 0x0000000182206a in physx::NpShape::setGeometry(physx::PxGeometry const&)
 #11 0x00000000c5b4e5 in BoxCollider::ScaleChanged()
 #12 0x00000000c836a9 in PhysicsManager::SyncTransforms()
 #13 0x00000000c96ba0 in PhysicsModule::AutoSyncTransforms()
 #14 0x00000000e3328e in ParticleSystem::BeginUpdateAll()
 #15 0x00000000e33e32 in ParticleSystem::InitializeClass()::PreLateUpdateParticleSystemBeginUpdateAllRegistrator::Forward()
 #16 0x000000009d0c8e in PlayerLoop()
 #17 0x0000000035f0e6 in -[PlayerAppDelegate UpdatePlayer]
 #18 0x00000095e1e336 in __NSFireTimer
 #19 0x000000946c8b96 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
 #20 0x000000946c86ad in __CFRunLoopDoTimer
 #21 0x000000946c814e in __CFRunLoopDoTimers
 #22 0x000000946bfb10 in __CFRunLoopRun
 #23 0x000000946bf01a in CFRunLoopRunSpecific
 #24 0x000000946bee0b in CFRunLoopRunInMode
 #25 0x00000093dbf396 in RunCurrentEventLoopInMode
 #26 0x00000093dbf182 in ReceiveNextEventCommon
 #27 0x00000093dbef7b in _BlockUntilNextEventMatchingListInModeWithFilter
 #28 0x0000009257d2d9 in _DPSNextEvent
 #29 0x00000092ce2c0b in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
 #30 0x00000092ce2535 in -[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:]
 #31 0x00000092571f7a in -[NSApplication run]
 #32 0x0000009253efe2 in NSApplicationMain
 #33 0x0000000035ea07 in PlayerMain(int, char const**)
 #34 0x0000009f7b3395 in start
 Stacktrace:
 
 
 Native stacktrace:
 
     0   libsystem_kernel.dylib              0x9f8e2496 __pthread_kill + 10
     1   libsystem_c.dylib                   0x9f842a34 abort + 141
     2   Candy Planet_1.5.7_171129_RELEASE   0x00d04c59 _Z12HandleSignaliP9__siginfoPv + 41
     3   libmono.0.dylib                     0x0d2c4404 mono_chain_signal + 69
     4   libmono.0.dylib                     0x0d21cff8 mono_sigsegv_signal_handler + 231
     5   libsystem_platform.dylib            0x9f9bce5b _sigtramp + 43
     6   ???                                 0xffffffff 0x0 + 4294967295
     7   Candy Planet_1.5.7_171129_RELEASE   0x004518b2 _ZN13MemoryManager18RegisterAllocationEPvmRK10MemLabelIdPKcS5_i + 98
     8   Candy Planet_1.5.7_171129_RELEASE   0x0044eff7 _ZN13MemoryManager8AllocateEmmRK10MemLabelId15AllocateOptionsPKci + 1063
     9   Candy Planet_1.5.7_171129_RELEASE   0x0044e565 _Z15malloc_internalmmRK10MemLabelId15AllocateOptionsPKci + 117
     10  Candy Planet_1.5.7_171129_RELEASE   0x00c95683 _ZN16NovodexAllocator8allocateEmPKcS1_i + 67
     11  Candy Planet_1.5.7_171129_RELEASE   0x01a17549 _ZN5physx6shdfnd10Foundation19AlignCheckAllocator8allocateEmPKcS4_i + 57
     12  Candy Planet_1.5.7_171129_RELEASE   0x01a168cf _ZN5physx6shdfnd9Allocator8allocateEmPKci + 63
     13  Candy Planet_1.5.7_171129_RELEASE   0x018a27ff _ZN5physx14PxsAABBManager18setDynamicAABBDataEjRKNS_18PxcAABBDataDynamicE + 1023
     14  Candy Planet_1.5.7_171129_RELEASE   0x018837bf _ZN5physx2Sc8ShapeSim16onGeometryChangeEv + 495
     15  Candy Planet_1.5.7_171129_RELEASE   0x01865808 _ZN5physx2Sc9RigidCore13onShapeChangeERNS0_9ShapeCoreENS_7PxFlagsINS0_21ShapeChangeNotifyFlag4EnumEjEENS4_INS_11PxShapeFlag4EnumEhEE + 56
     16  Candy Planet_1.5.7_171129_RELEASE   0x0182206a _ZN5physx7NpShape11setGeometryERKNS_10PxGeometryE + 362
     17  Candy Planet_1.5.7_171129_RELEASE   0x00c5b4e5 _ZN11BoxCollider12ScaleChangedEv + 133
     18  Candy Planet_1.5.7_171129_RELEASE   0x00c836a9 _ZN14PhysicsManager14SyncTransformsEv + 1065
     19  Candy Planet_1.5.7_171129_RELEASE   0x00c96ba0 _ZN13PhysicsModule18AutoSyncTransformsEv + 32
     20  Candy Planet_1.5.7_171129_RELEASE   0x00e3328e _ZN14ParticleSystem14BeginUpdateAllEv + 670
     21  Candy Planet_1.5.7_171129_RELEASE   0x00e33e32 _ZZN14ParticleSystem15InitializeClassEvEN52PreLateUpdateParticleSystemBeginUpdateAllRegistrator7ForwardEv + 34
     22  Candy Planet_1.5.7_171129_RELEASE   0x009d0c8e _Z10PlayerLoopv + 974
     23  Candy Planet_1.5.7_171129_RELEASE   0x0035f0e6 -[PlayerAppDelegate UpdatePlayer] + 454
     24  Foundation                          0x95e1e336 __NSFireTimer + 97
     25  CoreFoundation                      0x946c8b96 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
     26  CoreFoundation                      0x946c86ad __CFRunLoopDoTimer + 1213
     27  CoreFoundation                      0x946c814e __CFRunLoopDoTimers + 350
     28  CoreFoundation                      0x946bfb10 __CFRunLoopRun + 2192
     29  CoreFoundation                      0x946bf01a CFRunLoopRunSpecific + 506
     30  CoreFoundation                      0x946bee0b CFRunLoopRunInMode + 123
     31  HIToolbox                           0x93dbf396 RunCurrentEventLoopInMode + 268
     32  HIToolbox                           0x93dbf182 ReceiveNextEventCommon + 494
     33  HIToolbox                           0x93dbef7b _BlockUntilNextEventMatchingListInModeWithFilter + 83
     34  AppKit                              0x9257d2d9 _DPSNextEvent + 1227
     35  AppKit                              0x92ce2c0b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1742
     36  AppKit                              0x92ce2535 -[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:] + 132
     37  AppKit                              0x92571f7a -[NSApplication run] + 943
     38  AppKit                              0x9253efe2 NSApplicationMain + 1368
     39  Candy Planet_1.5.7_171129_RELEASE   0x0035ea07 _Z10PlayerMainiPPKc + 1143
     40  libdyld.dylib                       0x9f7b3395 start + 1
 
 Debug info from gdb:
 
 
 =================================================================
 Got a SIGABRT while executing native code. This usually indicates
 a fatal error in the mono runtime or one of the native libraries 
 used by your application.
 =================================================================
 

I don't know what cause this error. I checked every static references and null it when the gameobject is distroyed, remove listeners on OnDestroy(), et cetra... It doesn't happen on all devices. Only Mac Mini. And the allocation attempt is triggered by Unity's PhysicsManager.cpp

Can anyone give some advices?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by NGC6543 · Dec 01, 2017 at 03:03 AM

It turns out that on Mac Mini(with internal GPU Intel HD Iris / HD Graphics 5000), setting Color Space to "Linear" causes the issue. I switched it back to "Gamma" space, and the problem no longer occurs.

I think Unity Dev should know this.

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
avatar image
0

Answer by MaxGuernseyIII · Nov 30, 2017 at 12:28 PM

I'm sure there are memory profilers for Unity just like there are for everything else. Those are the easiest way but probably not free. You may also try looking to see if MonoDevelop has something useful for you and seeing if you can get it working on a Mac.

Assuming you don't want to or can't find/buy a memory profiler that works for unity on a Mac Mini, another option is to perform something akin to a binary search.

  1. Duplicate your scene.

  2. Verify that the problem is still there.

  3. Remove half the stuff in it.

  4. If the problem is still there, chop away another half of the stuff.

  5. If the problem isn't there, re-duplicate and remove the complementary set of things.

  6. Repeat as needed until you find the problem game object.

  7. Repeat as needed until you find the offending script.

Of course, it's not as simple as a dumb binary search through a sorted list. There are dependencies to manage and some of those dependencies are separate on-disk artifacts (like a material or whatever).

The basic rule of just ruling out pieces of content is the safest, surest path, though. Doing so in as close to as binary a fashion as you can will speed things up a little.

Comment
Add comment · Show 1 · 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 NGC6543 · Dec 01, 2017 at 03:00 AM 0
Share

Thanks for your advice! But the issue seems to be caused by hardware + Unity error.

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

121 People are following this question.

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

Related Questions

What is the correct way to store circular references in Unity? 1 Answer

Asset import did not unload metadata path. This will leak memory. File a bug with repro steps please. 1 Answer

Unity 5.6.1 Editor Freezing every few seconds from new project 1 Answer

Ml Agents release 19 training is freezing. Unity out of memory. 1 Answer

Application crashes when loading multiple assetbundle,loading multiple assetbundle causes crash with memory warning 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