Change this:
- (NSData *)extractFloatArrayFromElement:(TBXMLElement *)element
{
// element is <source>
NSMutableData *floatData = [NSMutableData data];
TBXMLElement *floatElement = [TBXML childElementNamed:@"float_array" parentElement:element];
NSString *stringValues = [TBXML textForElement:floatElement];
NSArray *values = [stringValues componentsSeparatedByString:@" "];
for (NSString *value in values) {
float floatValue = [value floatValue];
[floatData appendBytes:&floatValue length:sizeof(floatValue)];
}
return floatData;
}
To this:
- (NSData *)extractFloatArrayFromElement:(TBXMLElement *)element
{
@autoreleasepool {
// element is <source>
NSMutableData *floatData = [NSMutableData data];
TBXMLElement *floatElement = [TBXML childElementNamed:@"float_array" parentElement:element];
NSString *stringValues = [TBXML textForElement:floatElement];
NSArray *values = [stringValues componentsSeparatedByString:@" "];
for (NSString *value in values) {
float floatValue = [value floatValue];
[floatData appendBytes:&floatValue length:sizeof(floatValue)];
}
return floatData;
}
}
This assumes that componentsSeparatedByString:
is the source of a ton of autoreleased objects. If that doesn't help, then:
- sort the report in the Allocations Instrument by # of bytes
- turn on "only track live objects" (or whatever it is called)
- turn on "track reference count events"
- click through to the objects and then click through to the creation of a single object
That should tell you what in your code is triggering the allocation. From there, it is a matter of making the memory usage more efficient.