I have a rather difficult to trace problem with memory management that is related to OpenGL code. I am 99% certain the problem is a memory leak, but am finding the exact problem difficult to trace.
The following code snippet shows the call to glDrawArrays()
inside of a block which is inside of an instance method of my own custom object.
My iPad app crashes IF and ONLY IF the following conditions are met:
1. I must have compiled the app with Xcode 6.4.
Compiling the app under Xcode 6.2 makes the problem go away.
2. I must be running the app on a 32-bit iPad for the app to crash.
On 64-bit iPads, the app does not crash (Xcode 6.2, Xcode 6.4). On any Simulator running in Xcode 6.4 or 6.2, the app does not crash. The app ONLY crashes on 32-bit physical hardware.
typedef struct {
int startPointIndex;
int pointsNumber;
} ATEdgeGeometryIndexes;
typedef enum ATEdgeGeometryType {
ATEdgeGeometryTypeLine = 0,
ATEdgeGeometryTypeZeroPoint,
ATEdgeGeometryTypeNotches,
ATEdgeGeometryTypeZoneC,
ATEdgeGeometryTypeZoneD,
ATEdgeGeometryTypeAngleCircle,
ATEdgeGeometryTypePerpendicular,
ATEdgeGeometryTypeRotatedArc,
ATEdgeGeometryTypeNumber
} ATEdgeGeometryType;
typedef enum ATEdgeRulerType {
ATEdgeRulerTypeNormal = 0,
ATEdgeRulerTypeShadow,
ATEdgeRulerTypeNumber
} ATEdgeRulerType;
union _ATMatrix4 {
struct {
ATFloat m00, m01, m02, m03;
ATFloat m10, m11, m12, m13;
ATFloat m20, m21, m22, m23;
ATFloat m30, m31, m32, m33;
};
ATFloat m[16];
} ATMatrix4Attributes;
typedef union _ATMatrix4 ATMatrix4;
typedef struct {
ATMatrix4 lineMatrix;
ATMatrix4 notchesMatrix;
BOOL zeroPointOnScreen;
GLKVector4 color;
} ATEdgeRuler;
@interface ATLineEdgeTool () {
ATEdgeRuler rulers[ATEdgeRulerTypeNumber];
ATEdgeRuler arrayRulers[32];
ATEdgeGeometryIndexes _geometryIndexes[ATEdgeGeometryTypeNumber];
}
-(void) render {
// do some stuff
void (^drawEdgeRuler)(ATEdgeRuler) = ^(ATEdgeRuler ruler) {
// do some more stuff
glDrawArrays(GL_LINE_STRIP, _geometryIndexes[ATEdgeGeometryTypeNotches].startPointIndex,
_geometryIndexes[ATEdgeGeometryTypeNotches].pointsNumber);
}
drawEdgeRuler(rulers[ATEdgeRulerTypeNormal]);
}