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

4

13

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?

Alcestis answered 24/9, 2015 at 7:16 Comment(11)
Please show the stacktrace.Houseroom
The strange thing is I don't get any stacktrace most of the time. Just little three lines and the app is gone!Alcestis
Do as the error suggest and set a breakpoint in malloc_error_break and print a stack trace from there.Smoothbore
@casey, I did it with no stack track except the above error. prntscr.com/8kb4ge Sep 25 18:49:26 [AppName][10765] <Error>: CGBitmapContextInfoCreate: unable to allocate 1971200 bytes for bitmap data [AppName](10765,0xb029b000) malloc: *** mach_vm_map(size=1048576) failed (error code=3) *** error: can't allocate region securely *** set a breakpoint in malloc_error_break to debugAlcestis
@SunilChauhan I don't suppose you've managed to figure this out yet? I'm working on an app that's also experiencing this and only on iOS 9. Memory usage keeps slowly rising and I constantly see the malloc error. No idea what could be causing it, as ARC should be taking care of this and it works on iOS 8 and under. Are you using SQLite by any chance?Lias
@Dids: No, I have not figured this out yet, neither any clues. I don't use SQLite in the app. I also tested this in iOS 9.0.1 as well with same situation.Alcestis
@SunilChauhan Hmm, okay. What about any C-code or any low-level OS code? In my case, I'm accessing the network interfaces and getti g the amount of bytes sent/received.Lias
@Dids: I don't have C code much either. I searched entire app form malloc() and checked if it has some issues, but those are fine too.! Do you have this issue in iPhone4s/iPhone5/iPhone5c with iOS 9 only? My code works pretty well with iOS 9 with 64 bit architecture.Alcestis
@SunilChauhan 5S in my case, so it's 64-bit. Darn, was hoping it had something to do with manual mallocs. It's hard to rule it out as an iOS 9 bug though.Lias
Asked for Apple for help. Lets see what happens.Alcestis
@SunilChauhan Just wanted to add that I'm now also seeing this in another app that's definitely not doing anything odd such as manual malloc()'ing. Has to be a bug with iOS.Lias
A
3

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

Alcestis answered 27/10, 2015 at 6:9 Comment(1)
I'm using textview for link but still this issue occurred any other solution ?Hexylresorcinol
U
2

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.

Uniseptate answered 9/10, 2015 at 8:55 Comment(2)
Thanks, but this not the case in my app.Alcestis
You better run your app in the simulator, trying to reproduce the crash. Then set debug at where it crash and check for as much everything as possible.Uniseptate
I
1

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.

Intervocalic answered 11/4, 2016 at 7:6 Comment(0)
B
-1

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

Boner answered 12/10, 2016 at 2:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.