Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
521 views
in Technique[技术] by (71.8m points)

ios - Malloc error "can't allocate region" failed with error code 12. Any idea how to resolve this?

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 allocate region
*** set a breakpoint in malloc_error_break to debug

If i set a breakpoint to that line that occurs the error, i dont know what i have to search specially for. In instruments i have checked the allocations and the value is increasing until 14,5 GB of all allocations.

Can someone give me help?
brush51

EDIT 1:
More informations:
- I am trying this in the simulator, not on the iOS device.
- Thats all of the output(i am getting this error more times). - the error occurs on this line:

NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest *fetchREntitySetsCards = [[[NSFetchRequest alloc] init] autorelease];
//NSFetchRequest *fetchREntityRelCardsAnswersNotes = [[[NSFetchRequest alloc] init] autorelease];

NSEntityDescription *entitySetsCards = [NSEntityDescription entityForName:@"EntitySetsCards" inManagedObjectContext:context];
//NSEntityDescription *entityRelCardsAnswersNotes = [NSEntityDescription entityForName:@"EntityRelCardsAnswersNotes" inManagedObjectContext:context];
setEntity:entityCard];
[fetchREntitySetsCards setEntity:entitySetsCards];
//[fetchREntityRelCardsAnswersNotes setEntity:entityRelCardsAnswersNotes];

NSArray *fetchedObjSetsCards    = [context executeFetchRequest:fetchREntitySetsCards error:&error];
//The error is here--->
//NSArray *fetchedObjRelCardsAnswersNotes   = [context executeFetchRequest:fetchREntityRelCardsAnswersNotes error:&error];


//Badges für TabBarItem Inbox setzen
setsCount = [context countForFetchRequest:fetchREntityUserSet error: &error];
cardsCount = [context countForFetchRequest:fetchREntityCard error: &error];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...