small medium large xlarge

Generic-user-small
25 Dec 2010, 21:47
Don Ky (5 posts)

Hello all I was viewing the bill dudney episode on memory management and ran into an issue during my build. It appears that my Movie object is still playing after being released?

Here is the code:

`

import <Foundation/Foundation.h>

#import “Movie.h”

int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

Movie *movie = [[Movie alloc] initWithTitle:@"Iron Man"
								  andRating:5
									andYear:2009];

//movie.title = @"iron man";
//movie.rating = 5;

//[movie play];
//NSLog(@"Our movie is %@", movie);

NSLog(@"The retain count is: %d", [movie retainCount]);

[movie release];

[movie play]; //sending a message to a object already released.


[pool drain];
return 0; } `

The app continues to run with no issues as if the object still has a retain count? whereas in the video Dudney gets a error in gdb.

Thanks for any help.

Generic-user-small
25 Dec 2010, 21:47
Don Ky (5 posts)

import <Foundation/Foundation.h>

#import “Movie.h”

int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

Movie *movie = [[Movie alloc] initWithTitle:@"Iron Man"
								  andRating:5
									andYear:2009];

//movie.title = @"iron man";
//movie.rating = 5;

//[movie play];
//NSLog(@"Our movie is %@", movie);

NSLog(@"The retain count is: %d", [movie retainCount]);

[movie release];

[movie play]; //sending a message to a object already released.


[pool drain];
return 0; }
Generic-user-small
25 Dec 2010, 21:48
Don Ky (5 posts)

sorry guys tried to wrap the code in `` tags but no luck. I just pasted the code in previous response.

  You must be logged in to comment