当我在iPhone上运行而不是在模拟器上运行时,我遇到了这个可怕的错误。我尝试过运行僵尸工具、分配工具和突然终止工具,但后者不能在设备上运行。这些工具不会突出显示任何不寻常的内容。也许我用错了,但这看起来很简单。
基本上,当我向应用程序添加了第二组数据数组时,我得到了这个错误,在模拟器上,它使用了大约70MB,而没有添加第二组数据数组,它使用了20到40MB。看起来我真的是内存不足(iPhone 4s),但从我所读到的来看,这不太可能。从分配工具来看,最后发生的事情是VM分配,但我不知道它是否成功。这个仪器根本不会说什么。
有没有人有办法在Xcode6上追踪到这样的问题并在设备上运行?(我的应用程序正在使用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之外,没有其他信息可以跟踪它。堆栈跟踪只是将setup方法显示为最后一次调用。我认为问题出在我的视图控制器上,但经过多次尝试和错误之后,它认为它必须是这样的,但可能有一个我看不到的微妙问题。这是我的视图控制器代码,它调用了立即崩溃的setup方法--您可能只需要查看最后的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];
}发布于 2015-03-09 03:17:42
选择视图菜单、导航器、断点导航器(⌘7)。
然后单击breakpoint导航栏左下角的+,并选择"Add Exception Breakpoint“。按住Control键并单击(或右键单击)结果断点,并将其更改为在所有Objective-C异常时中断。
然后,作为最后一步,再次右键单击断点并选择Move breakpoint to>User。这使断点成为所有项目的全局断点。
一旦添加了异常断点,Xcode就更有可能在错误的源代码行中断。这并不完美,但它确实使您更有可能看到实际的行,而不是main.m中的一行,这是没有用的。
https://stackoverflow.com/questions/28930027
复制相似问题