PDA

View Full Version : Instruments Question About GeneralBlock-0




Darkroom
Jul 6, 2009, 08:00 PM
in testing my app for memory leaks and object allocation, i've noticed that my "GeneralBlock-0" seems to only grow, and quickly turn to and maintain ominous red, while the other bars grow and shrink...

i don't really understand Instruments that well, so is this a bad thing?



kpua
Jul 6, 2009, 11:04 PM
Looks like you're mallocing a lot of zero-length buffers. An odd thing to do. Try looking at one of the stack traces to see where you're doing it.

Darkroom
Jul 6, 2009, 11:13 PM
Looks like you're mallocing a lot of zero-length buffers. An odd thing to do. Try looking at one of the stack traces to see where you're doing it.

i'm sorry, but what? i don't know what you are telling me :o i gather that this is a problem, then?

kpua
Jul 7, 2009, 12:49 AM
Your program is doing essentially this very often:

malloc( 0 )

which allocates 0 bytes. This probably isn't really free... The malloc system probably still does the book-keeping for these allocations, which still takes space.


To figure out where this is happening, click the little arrow next to GeneralBlock-0. Click on one of the entries in the "Object Address" column and then click the button at the bottom that shows the sidebar. This shows the stack trace for the allocation. That will show you where you program is doing this funny allocation. (I'd suggest looking at several of these to make sure the location is the same each time.)

Darkroom
Jul 7, 2009, 01:06 AM
Your program is doing essentially this very often:

malloc( 0 )

which allocates 0 bytes. This probably isn't really free... The malloc system probably still does the book-keeping for these allocations, which still takes space.


To figure out where this is happening, click the little arrow next to GeneralBlock-0. Click on one of the entries in the "Object Address" column and then click the button at the bottom that shows the sidebar. This shows the stack trace for the allocation. That will show you where you program is doing this funny allocation. (I'd suggest looking at several of these to make sure the location is the same each time.)

humm... ok, so it appears from the stack trace that this is happening in my main.m file, on line 14 (from stack trace = appAddress/main.m:14)

i didn't change this file at all... it's the main.m that was automatically included when choosing a View-Based Application template. i know this is not an iPhone Development forum, but i posted here because my concern is with Instruments.


#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); //Line 14
[pool release];
return retVal;
}


or maybe it's related to Quartz Core and Core Graphics Framework? what should i do?

kpua
Jul 7, 2009, 02:41 AM
main() is the "bottom" of the stack trace, giving the least amount of information because it calls everything else. You need to show the "top" of the stack by scrolling down in the stack trace window.

Darkroom
Jul 7, 2009, 02:55 AM
i've attached this sample project which does the same thing... if you could take a lot at it and tell me what the problem is that would be great. it appears that my error is with using the core graphic framework, or something... perhaps i've set it up incorrectly? not releasing something, maybe?

[EDIT] it seems like the OP in this thread (http://stackoverflow.com/questions/1053400/thousands-of-new-0-size-objects-being-added-to-my-net-total-every-second-should) is experiencing the same problem. is this a bug in simulator? or is it really slowing down my app for real?

Darkroom
Jul 18, 2009, 01:25 PM
this seems to only happen in the iPhone Simulator, as the same thing didn't occur while using instruments for on-device testing.