small medium large xlarge

19009479_n00_pragsmall
05 Jan 2009, 00:25
Ray Schamp (6 posts)

When I follow Chapter 7, Instruments never displays my leak. Everything to this point has gone very smoothly. My code is as follows:

// Greeter.h
#import <Cocoa/Cocoa.h>


@interface Greeter : NSObject {

}
- (void) sayHello;

@end
// Greeter.m
#import "Greeter.h"


@implementation Greeter

- (void) sayHello {
	NSLog(@"Hello, world!");
}

@end

</code>

// main.m
#import <Cocoa/Cocoa.h>
#import "Greeter.h"

int main(int argc, char *argv[])
{
	Greeter * myGreeter = [[Greeter alloc] init];
	[myGreeter sayHello];
    return NSApplicationMain(argc,  (const char **) argv);
}

My Overview dropdown has the following checked: * Active SDK: Mac OS X 10.5 (Project Setting) * Active Configuration: Release * Active Executable: HelloWorld * Active Architecture: i386

When I open Project -> Edit Project Settings and choose Configuration: All Configurations / Show: All Settings / Filter: garbage, I see a setting Objective-C Garbage Collection Value: Unsupported.

Instruments just doesn’t show anything happening, no matter how long I let it run. Any ideas of what’s going on?

I’m running OS 10.5.6 / Instruments v. 1.5 (47) / XCode 3.1.2

I wish I could preview this post.

-Ray

Images_pragsmall
07 Jan 2009, 04:16
Al Anderson (1 post)

I thought I was doing something wrong as well. I had no leaks that Instruments picked up. I have a similar setup.

Al

Daniel_pragsmall
08 Jan 2009, 13:06
Daniel H Steinberg (98 posts)

Oops sorry – I missed this before doing the latest beta. You might want to post items like this to the errata. I’ll give this a try this weekend and make sure it’s still not working. Bill has noticed some things are different in his Core Animation projects with respect to Garbage Collection as of 10.5.6.

Daniel

Daniel_pragsmall
09 Jan 2009, 11:50
Daniel H Steinberg (98 posts)

I just reran my code on two machines (you can download it and see it as HelloWorld3 in the ObjectsAndProperties folder. I built the project and then ran the release as an executable from Instruments. About ten seconds in a modal window popped up asking me to enter my password and then (once I did) the leak was reported.

Both machines are running 10.5.6 with the same settings you report above. I’m not saying you are wrong, I’m saying that I’m not seeing it here on either machine. I’ll ask the tech reviewers to poke at this example.

Thanks,

Daniel

Sean pic_pragsmall
10 Jan 2009, 13:37
Sean Johnson (1 post)

I also see the link fine (after typing my password). Maybe you missed the password dialog?

Thanks, Sean

Generic-user-small
19 Jan 2009, 14:00
Achint Sandhu (1 post)

Hi,

I have a similar issue with an identical environment and I got the password dialog and did type in the password.

The difference is that I see 1 leak for an NSURL object being leaked and no leaks on the Greeter object.

Using the project provided in HelloWorld3, I see 2 leaks NSURL and Greeter.

I’ve compared my code and project settings to the example project and can’t see what the difference is.

Cheers, Achint

Generic-user-small
23 Jan 2009, 12:56
Jacob Rohde (4 posts)

I also have the same problem. Instruments doesn’t report my leak!

I thought that maybe it could be because it is only a single small object, so I put the creation of the Greeter object in a for loop, and created 500 of them, and when I ran that through Instruments it lit up like a Christmas tree.

Yeslekmc_2_pragsmall
02 Feb 2009, 17:47
Kelsey McClanahan (10 posts)

Instruments DOES report the Greeter leak on my system. My result matches the screen snapshot in the book.

My current development environment:

iMac 24” White 2.16 GHz Intel Core 2 Duo w/ 4GB RAM Mac OS X 10.5.6 (production, not a developer release) Xcode 3.1.2 Instruments 1.5

Generic-user-small
08 Feb 2009, 14:24
George Irwin (1 post)

With an identical setup on a Mac Pro (Quad-Core Xeon), “Instruments” apparently fails to capture all the memory leaks.

I have consistently captured 1 memory leak when 2 instances of the Greeter Class are generated during a run. By incrementally increasing the number of instances, a pattern is revealed for the number of leaks. One instance shows 0 leaks, 2 instances shows 1 leak, 3 through to 13 instances have the number of leaks captured as 2 less than the number of instances.

It appears that the inconsistency is attributable to “Instruments”.

Generic-user-small
16 Feb 2009, 20:23
kristof (1 post)

Maybe to make the issue more obvious you could insert the problematic code in a while loop like the one found in the programming objective-c 2.0 screencast episode 2 (in the event loop chapter).

Image_pragsmall
16 May 2009, 17:53
Mark Boszko (4 posts)

Been going through the book this morning, and enjoying the tone, even though so far it doesn’t explain a lot of the background you need to really understand some of what’s going on. But as it is a Quick Start, perhaps that’s the intent.

I’ll chime in here and say that Instruments doesn’t report the leak on my system unless I have 4 or 5 unreleased instances of Greeter going at once, and the number of leaks reported is roughly 2 less than actual, like George Irwin’s report.

MacBook Pro 2 GHz Intel Core Duo, 2 GB SDRAM Mac OS X 10.5.6 Xcode 3.2 Instruments 1.5

I’m completely new to Instruments, so I don’t have any insight into what may be wrong, but it definitely doesn’t report any leaks if I only have 1 or 2 instances unreleased.

You must be logged in to comment