Ошибка памяти iPhone - при использовании Build & Debug, как отлаживать? - PullRequest
0 голосов
/ 27 января 2010

Я новичок и мне нужна помощь с приложением для iPhone, работающим на симуляторе. Приложение отлично работает, если Build & Run или Build & Run - точки останова отключены, но работает, когда запущены функции Build & Debug - точки останова. Любая помощь или мысли будут с благодарностью. Lon

Особенности: Точки останова не установлены, никогда не доходят до видимых результатов симулятора, кажется, что он дует на этапе инициализации, прежде чем он сможет генерировать какой-либо вывод. Источник приложения - пример DrinkMixer, в книге Дэна и Трейси Пилоне «Разработка First iPhone» (пример, созданный до страницы 280).

Дует с этим сообщением об ошибке:

Attaching to process 970.
Pending breakpoint 1 - "*0x01c1b001" resolved
Program received signal:  “EXC_BAD_ACCESS”.
No memory available to program now: unsafe to call malloc
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)
No memory available to program now: unsafe to call malloc
---
Leaks:
The only object noted as "leaked Object" is:
Leaked Object   #   Address Size    Responsible Library Responsible Frame
Malloc 128 Bytes <blank> 0x3c11950   128Bytes   CoreGraphics    open_handle_to_dylib_path
___

Object Allocations shows (Highest at top = CFString):

Category   --- Overall Bytes  --  #Overall    -- Live Bytes --  #Living
* All Allocations * 497kb      #5888    496kb   #5878   10
CFString                42kb     #1126   42kb       
Malloc  32.00 KB    32kb     #1     32kb
Malloc 1.00 KB  29kb     #29        29kb
Malloc 8.00 KB  24kb     #3     24kb    
Malloc 32 Bytes 20.81kb  #666   20.75kb
Malloc 1.50 KB  19.5kb    #13       19.5kb 
CFDictionary (key-store)    17.64kb  #159  17.64kb 

(note:  Except for "All Allocations, the  #Living is the same as #Overall)
---

List of Calls from Debugger:

#0  0x01c1b010 in CFStringCreateByCombiningStrings
#1  0x023a0779 in LoadFontPathCache
#2  0x023a096b in Initialize
#3  0x023a0f3e in GSFontCreateWithName
#4  0x003d4575 in +[UIFont boldSystemFontOfSize:]
#5  0x002cddaa in +[UINavigationButton defaultFont]
#6  0x002d9e37 in -[UINavigationButton initWithValue:width:style:barStyle:possibleTitles:tintColor:]
#7  0x002cdc75 in -[UINavigationButton initWithImage:width:style:]
#8  0x00468eeb in -[UIBarButtonItem(Static) createViewForNavigationItem:]
#9  0x002d1b56 in -[UINavigationItem customRightView]
#10 0x002d20e3 in -[UINavigationItem updateNavigationBarButtonsAnimated:]
#11 0x002d1e1a in -[UINavigationItem setRightBarButtonItem:]
#12 0x00002e7b in -[RootViewController viewDidLoad] at RootViewController.m:41
#13 0x00313796 in -[UIViewController view]
#14 0x00311d92 in -[UIViewController contentScrollView]
#15 0x0031c2b4 in -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:]
#16 0x0031b32e in -[UINavigationController _layoutViewController:]
#17 0x0031cd1a in -[UINavigationController _startTransition:fromViewController:toViewController:]
#18 0x0031831a in -[UINavigationController _startDeferredTransitionIfNeeded]
#19 0x004362e4 in -[UILayoutContainerView layoutSubviews]
#20 0x035342b0 in -[CALayer layoutSublayers]
#21 0x0353406f in CALayerLayoutIfNeeded
#22 0x035338c6 in CA::Context::commit_transaction
#23 0x0353353a in CA::Transaction::commit
#24 0x00295ef9 in -[UIApplication _reportAppLaunchFinished]
#25 0x0029bb88 in -[UIApplication handleEvent:withNewEvent:]
#26 0x002976d3 in -[UIApplication sendEvent:]
#27 0x0029e0b5 in _UIApplicationHandleEvent
#28 0x023a3ed1 in PurpleEventCallback
#29 0x01bb6b80 in CFRunLoopRunSpecific
#30 0x01bb5c48 in CFRunLoopRunInMode
#31 0x00295e69 in -[UIApplication _run]
#32 0x0029f003 in UIApplicationMain
#33 0x00002ba0 in main at main.m:14

Код, включая строку № 41 (отмечена ниже), выглядит следующим образом. И спасибо за помощь в форматировании и комментарий:

#import "RootViewController.h"  
#import "DrinkDetailViewController.h";
#import "DrinkConstants.h"
#import "AddDrinkViewController.h"
@implementation RootViewController
@synthesize drinks, addButtonItem;
- (void)viewDidLoad {
    [super viewDidLoad];    
    //  add PATH for PLIST  
    NSString *path = [[NSBundle mainBundle] pathForResource:
                      @"DrinkDirections"  ofType:@"plist"]; 
    NSMutableArray *tmpArray = [[NSMutableArray alloc]                              initWithContentsOfFile:path];   
    self.drinks = tmpArray; 
    [tmpArray release];

// Next is Line #41 - I removed earlier empty lines & Comments

    self.navigationItem.rightBarButtonItem = self.addButtonItem;

}
- (IBAction) addButtonPressed: (id) sender {
    NSLog(@"Add button pressed!");

1 Ответ

0 голосов
/ 18 апреля 2010

Вы пробовали использовать инструменты и обнаружение NSZombie: http://www.markj.net/iphone-memory-debug-nszombie/

...