Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I know the issue is related to memory allocations, but I get it in only iOS 9, XCode 7. In XCode 6.4, iOS 8.4, it works just perfect, no issue at all at any ways. In iOS 9, XCode 7, it just crashes very frequently giving this error.

malloc: *** mach_vm_map(size=1048576) failed (error code=3) *** error: can't allocate region securely *** set a breakpoint in malloc_error_break to debug

Any suggestions? I am working on memory issues, but I wonder if there were too many memory issues, then why did it work in iOS 8.4 and not in iOS 9?

Also, I get all my UI whited out! Like navigation bar has no title, custom tabbar(RDVTabBar) is not visible, however, other view controller is there (it responds to the touch events, you can tap that area and the button positioned in that area acts!).

P.S. I don't get memory warning ever, neither applicationWillTerminate: method is being called!

Update: I found that this issue occurs in iPhone 5 and 4s only! (Non-64bit devices!)

Update 2: When the crash happens, I try to print one of the object and to print it, I again get the same error in debug mode: malloc: *** mach_vm_map(size=1048576) failed (error code=3) *** error: can't allocate region securely *** set a breakpoint in malloc_error_break to debug.

------------------ Update ------------------

Well, I found something here: I inspected my app in Instruments and detected that it occupies about 200mb of memory in iOS 8.4, and surprisingly iOS 9.* occupies 1.5 GB of the memory!!! This is something I don't understand! One app takes 200 mb of memory in iOS 8.4 and the same app takes over 1.5GB of memory on iOS 9! Not understandable at all! Any Idea?

like image 521
Sunil Chauhan Avatar asked Sep 24 '15 07:09

Sunil Chauhan


2 Answers

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).

like image 119
Sunil Chauhan Avatar answered Nov 13 '22 22:11

Sunil Chauhan


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.

like image 2
Eddie Avatar answered Nov 13 '22 23:11

Eddie