• 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
Re: Objective C++ memory management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Prev by Date: Re: Objective C++ memory management
  • Next by Date: CoreRecipesApp and 10.4.3
  • Previous by thread: Re: Objective C++ memory management
  • Next by thread: IBPalette problem
  • Index(es):
    • Date
    • Thread