(XCode 7 + iOS 9 + iPhone 4s/iPhone5 only) issue: “malloc: *** mach_vm_map(size=1048576) failed (error code=3)”

﹥>﹥吖頭↗ 提交于 2019-11-30 08:52:57

Well, I guess I have finally found the issue: Its definitely memory issue, but I had to search where. I found that I am using two third party labels namely: CXAHyperlinkLabel and STTweetLabel. When I removed those, my app just work fine!! The issue has been resolved but still I am confused why it did work (and still works) great in iOS 8.4 and eats up more than 1.5 GB of memory in iOS 9.0 and above!! If it has some issues with memory (I found some and fixed already, still), why it did work with iOS 8.*. So, my advice to any fellow who are having such issues, I recommend using UITextView for links (I did it and its nice replacement).

I've just experienced the exact issue as you (xcode7, on iPad 2, iOS 8.4).

<Error>: myApp(524,0x3cfda9dc) malloc: *** mach_vm_map(size=4060311552) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

So, I decide to ran on debug mode, and the app crash in the most unexpected place:

        [self.delegate discountPopupDoneClickWithDiscount:self.discount
                                                     type:self.discountType
                                         federalTaxEnable:self.federalTaxEnable
                                               federalTax:self.federalTax
                                                customTax:self.customTax];

Then I tried to find out what happened here, type po self.discount, turn out self.discount (it's a property with NSDecimalNumber type) return a very unsual value, like <å: 0xba123adr>. Strange, right? Also, when I try po [self discount], it yield NSDecimalNumber [_NSKeyedCoderOldStyleArray initialize]: Unrecognized selector send to instance. Pretty much clueless what to do here.

Solution:

I update the discount property from this:

@property (nonatomic, assign) NSDecimalNumber *discount;

to this:

@property (nonatomic, strong) NSDecimalNumber *discount;

And then everything's fine. Of course this isn't an exact answer/solution to your question, but this may help/give you a clue on what to do, somehow.

So strange. I had a very similar issue, where the app would continually increase memory consumption until eventually it would crash, but ONLY on iOS7 and iOS8. Sure enough, no issues with iOS9 and up.

Found out that a simple setting of [UILabel setText:text] for A LOT of collectionViewCells was the cause. WTF? They were weak, nonatomic. Why?

Ran the app in Instruments : Allocations. Before Instruments eventually crashed, I was able to isolate the memory consumption to __NSStringDrawingEngine, +[NSParagraphStyle _defaultWritingDirection] [UIFont fontWithName] or something to that nature.

Anyway, turns out the issue is that I was using the Text Styles types (Eg, Title 1, Title 2, Body, Caption, etc). Seemed logical to use at the time. But, I switched those over to System fonts, and no more memory issue and no more freezing.

So strange.

did you use the NSZombieObject enable,it will not release the zombie object,and may cause this crash.i hope it will help you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!