Malloc error “can't allocate region” failed with error code 12. Any idea how to resolve this?

前端 未结 3 2043
一个人的身影
一个人的身影 2020-12-08 15:11

i am getting this error and dont know what to do with that:

AppName(3786,0xa0810540) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can\'t         


        
相关标签:
3条回答
  • 2020-12-08 15:43

    I had this issue due to a recursive call in a view controller's viewWillLayoutSubviews. I was invalidating the layout of a collection view causing an endless cycle of repeatedly laying out views.

    0 讨论(0)
  • 2020-12-08 16:02

    Sounds strange, but I had the same behavior when main thread was overloaded.

    Memory usage was optimal enough: instruments shows no leaks and live memory was about 2Mb, no memory warnings while running on a device, all massive allocation was done inside autorelease pools etc.

    But there was very huge process of storing data to db (using Core Data) made on main thread. Just moving the storing code to background process like this

    dispatch_async(dispatch_get_global_queue
      (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
      BOOL result = NO;
      result = [[DataManager sharedInstance] storeGuestsToDB];
      dispatch_async(dispatch_get_main_queue(), ^{
      //finalization
      }
    }
    

    fixed my problem.

    0 讨论(0)
  • 2020-12-08 16:05

    Googling will reveal quite a few tutorials on using instruments to understand what is going on with your memory:

    How to debug memory leaks: (tutorial)
    http://www.raywenderlich.com/2696/how-to-debug-memory-leaks-with-xcode-and-instruments-tutorial

    And another:
    Finding Obj-C memory leaks (video)
    http://www.youtube.com/watch?v=R449qEuexNs&feature=related

    *There are many similar questions on stackoverflow you might benefit from.

    0 讨论(0)
提交回复
热议问题