У меня есть эта страшная ошибка, когда я запускаю iPhone, но не на симуляторе. Я пробовал использовать инструменты для зомби, выделения и внезапные окончания, но позже не будет работать на устройстве. Этими инструментами не выделяется ничего необычного. Возможно, я использую их неправильно, но это кажется довольно прямым.Отладка EXC_BAD_ACCESS на устройстве на Xcode 6
В основном я получаю эту ошибку, когда добавляю в приложение 2-й набор массивов данных, а на симуляторе он использует около 70 МБ, тогда как без 2-го набора он использует от 20 до 40 МБ. Это похоже на то, что я просто из памяти (iPhone 4s), но из того, что я прочитал, это маловероятно. Из инструмента распределения, последнее, что происходит, является распределением виртуальной машины, но я не знаю, было ли это успешным или что-то еще. Инструмент вообще ничего не говорит.
Есть ли у кого-нибудь метод отслеживания такой проблемы с Xcode 6 и работает на устройстве? (Мое приложение использует ARC.) Есть ли команда консоли отладчика, которую я должен знать?
Благодаря
PS: Я также объекты с поддержкой зомби в Xcode, но и никакой подсказки о ошибке.
Вот код, я попросил, чтобы оставлять сообщения:
//***************************************************/
// Process the constellation lines catalog for OpenGL
//***************************************************/
// Must create a set of polygon objects to be drawn separately
// Each with a vertex and index buffer
NSMutableString *constellationName = [[NSMutableString alloc] init];
NSMutableArray *constellationsTemp = [[NSMutableArray alloc] init];
// Do a points and lines scatter plot of the catalog data
int totalVertices = 0;
for (i=0; i<constellationLinesCatalogData.count;) {
constellationName = [[constellationLinesCatalogData objectAtIndex:i] objectAtIndex:CON_INDEX];
NSMutableArray *constellation = [[NSMutableArray alloc] init];
while ((i<constellationLinesCatalogData.count) && [[[constellationLinesCatalogData objectAtIndex:i] objectAtIndex:CON_INDEX] isEqualToString:constellationName]) {
NSMutableArray *constellationVerticesArray = [[NSMutableArray alloc] init];
NSMutableArray *constellationIndicesArray = [[NSMutableArray alloc] init];
while (![[[constellationLinesCatalogData objectAtIndex:i] objectAtIndex:STAR_INDEX] isEqualToString:@""]) {
cos_ra = cosf(GLKMathDegreesToRadians(
15*(
[[[constellationLinesCatalogData objectAtIndex:i] objectAtIndex:RA_INDEX] floatValue]
)
));
sin_ra = sinf(GLKMathDegreesToRadians(
15*(
[[[constellationLinesCatalogData objectAtIndex:i] objectAtIndex:RA_INDEX] floatValue]
)
));
cos_dec = cosf(GLKMathDegreesToRadians(
[[[constellationLinesCatalogData objectAtIndex:i] objectAtIndex:DE_INDEX] floatValue]
));
sin_dec = sinf(GLKMathDegreesToRadians(
[[[constellationLinesCatalogData objectAtIndex:i] objectAtIndex:DE_INDEX] floatValue]
));
NSArray *Position = [[NSArray alloc] initWithObjects:
[NSNumber numberWithFloat:cos_dec*cos_ra], // X
[NSNumber numberWithFloat:cos_dec*sin_ra], // Y
[NSNumber numberWithFloat:sin_dec], // Z
[NSNumber numberWithFloat:1.0],
nil];
NSArray *Color = [[NSArray alloc] initWithObjects:
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:1.0],
nil];
NSArray *TexCoord0 = [[NSArray alloc] initWithObjects:
[NSNumber numberWithFloat:1.0],
[NSNumber numberWithFloat:1.0],
nil];
NSArray *TexCoord1 = [[NSArray alloc] initWithObjects:
[NSNumber numberWithFloat:1.0],
[NSNumber numberWithFloat:1.0],
nil];
NSArray *Pointsize = [[NSArray alloc] initWithObjects:
[NSNumber numberWithFloat:DEFAULT_POINT_SIZE],
nil];
NSArray *constellationVertex = [[NSArray alloc] initWithObjects:
Position,
Color,
TexCoord0,
TexCoord1,
Pointsize,
nil];
[constellationVerticesArray addObject:constellationVertex];
[constellationIndicesArray addObject:[[NSNumber alloc] initWithUnsignedInteger:totalVertices]];
totalVertices++;
i++;
}
NSArray *figure = [[NSArray alloc] initWithObjects:
[[constellationLinesCatalogData objectAtIndex:i] objectAtIndex:CON_INDEX],
constellationVerticesArray,
constellationIndicesArray,
nil];
[constellation addObject:figure];
i++;
}
[constellationsTemp addObject:constellation];
}
NSArray *constellations = [[NSArray alloc] initWithArray:constellationsTemp copyItems:YES];
NSLog(@"constellations.count = %lu", (unsigned long)constellations.count);
NSLog(@"totalVertices = %d", totalVertices);
// Setup constellation buffers
Vertex constellationVertices[totalVertices];
GLuint constellationIndices[totalVertices*2];
Ну, эта проблема упорствует. Нет никакой информации, чтобы отслеживать его, кроме кода EXC_BAD_ACCESS 1. Трассировка стека просто показывает метод установки как последний вызов. Я думал, что проблема была в моем контроллере, но после большого количества проб и ошибок. Думаю, это должно быть так, как есть, но, может быть, есть тонкая проблема, которую я не вижу. Это мой взгляд контроллер код, который вызывает метод установки, который сразу же происходит сбой - вы, вероятно, нужно только посмотреть на настройках OpenGL в конце:
#import "GBStarFieldViewController.h"
#import "GBStarFieldView.h"
#define MOTION_UPDATE_INTERVAL (1/30) // seconds
@interface GBStarFieldViewController()
@end
@implementation GBStarFieldViewController {
int i;
CLLocationManager *locationManager;
CMMotionManager *motionManager;
GBStarFieldView *starFieldView;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"GBStarFieldViewController viewDidLoad invoked");
/****************************/
// Register for notifications
/****************************/
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self
selector:@selector(tapDetected:)
name:@"TapDetected"
object:nil];
[center addObserver:self
selector:@selector(pinchDetected:)
name:@"PinchDetected"
object:nil];
[center addObserver:self
selector:@selector(oneTouchPanDetected:)
name:@"OneTouchPanDetected"
object:nil];
[center addObserver:self
selector:@selector(twoTouchPanDetected:)
name:@"TwoTouchPanDetected"
object:nil];
/****************************************************/
// Setup location manager
/****************************************************/
if ([CLLocationManager locationServicesEnabled] && [CLLocationManager headingAvailable]) {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.headingFilter = kCLHeadingFilterNone;
locationManager.distanceFilter = kCLHeadingFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[locationManager requestAlwaysAuthorization];
}
} else {
NSLog(@"Error: Failed to get heading services");
}
/****************************************************/
// Setup motion manager
/****************************************************/
if ([CMMotionManager availableAttitudeReferenceFrames] & CMAttitudeReferenceFrameXTrueNorthZVertical) {
motionManager = [[CMMotionManager alloc] init];
[motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical];
motionManager.deviceMotionUpdateInterval = MOTION_UPDATE_INTERVAL;
} else {
NSLog(@"Error: Failed to get reference frame");
}
/*******************/
// Initialize OpenGL
/*******************/
// Create an OpenGL ES context and assign it to the view loaded from storyboard
starFieldView = (GBStarFieldView *)self.view;
starFieldView.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
[starFieldView setup];
}
Получаете ли вы какие-либо предупреждения о памяти? Поместите NSLog в эти обратные вызовы. – zaph
У вас есть символический журнал сбоев, который вы можете поделиться? –
Да, у меня есть NSLog в обратных вызовах памяти, но ни один из них не выпущен. – codesurfer