Re: Objective C++ memory management
Re: Objective C++ memory management
- Subject: Re: Objective C++ memory management
- From: Greg Parker <email@hidden>
- Date: Tue, 1 Nov 2005 11:49:11 -0800
I have a pointer to a C++ object within my ObjC class:
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
pbmp = new BitMapMgr; // Call the
constructor
}
return self;
}
- (void)dealloc {
delete pbmp; // Call the
destructor
}
However, when I run the application within Xcode print statements
confirm that only the constructor gets called. What is the correct
way
to release the memory allocated for pbmp?
Your C++ memory management looks correct; that's the right place to
put your new and delete. If your destructor isn't being called, it's
probably because your dealloc method itself isn't being called. You
may have a problem with memory management of QuartzView objects
elsewhere.
Note that your dealloc method must call [super dealloc]. Otherwise,
the QuartzView object itself will never be destroyed.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden