• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Instruments Leaks newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Instruments Leaks newbie question


  • Subject: Instruments Leaks newbie question
  • From: "Glenn Bloom" <email@hidden>
  • Date: Fri, 19 Sep 2008 16:53:18 -0400

I'm new to using Instruments and to test the Instruments Leaks template I came up with the following simple test:

1. I created a new Cocoa application using the Cocoa Document-Based Application template.  

2. Then I created an empty class named Duck, inheriting from NSObject.  

3. Then I placed the following code into main.m, inside the main method, above its return statement:

printf("In main.m: Intentional leak - A Duck is created and not released.\n");

        Duck *duckA;

duckA = [[Duck alloc] init];

printf("In main.m: Duck retainCount:%d\n\n", [duckA retainCount]);


4. Finally, in MyDocument.m, I overrode the windowControllerDidLoadNib: method as follows, creating three additional Duck object:


- (void)windowControllerDidLoadNib:(NSWindowController *) aController

{

    [super windowControllerDidLoadNib:aController];


    printf("In MyDocument.m: Intentional leak - A Duck is created and not released.\n");

Duck *duck;

duck = [[Duck alloc] init];

printf("In MyDocument.m: Duck retainCount:%d\n\n", [duck retainCount]);

        printf("In MyDocument.m: Intentional leak - A Duck is created and not released.\n");

Duck *duck1;

duck1 = [[Duck alloc] init];

printf("In MyDocument.m: Duck retainCount:%d\n\n", [duck1 retainCount]);

        printf("In MyDocument.m: Intentional leak - A Duck is created and not released.\n");

Duck *duck2;

duck2 = [[Duck alloc] init];

printf("In MyDocument.m: Duck retainCount:%d\n\n", [duck2 retainCount]);

}


Now here's my question:  How come the Instruments leaks template identifies all three leaks from inside the windowControllerDidLoadNib: method, but not the one from inside main.m?  Am I not configuring this template correctly?  Or am I offbase even asking this, as adding code to main.m would not be normally required anyway?


thanks for anyone's help 

glennB

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Instruments Leaks newbie question
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: libjpeg
  • Next by Date: Re: Custom component fails to load images by name in a IBPlugin
  • Previous by thread: Re: Custom component fails to load images by name in a IBPlugin
  • Next by thread: Re: Instruments Leaks newbie question
  • Index(es):
    • Date
    • Thread