• 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
Tracked down the over-release bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tracked down the over-release bug


  • Subject: Tracked down the over-release bug
  • From: "Theodore H. Smith" <email@hidden>
  • Date: Sun, 12 Jun 2005 23:21:58 +0100

Thanks to everyone who gave me their answers. I did understand the basics of Cocoa memory allocation. However I managed to forget to write an assignment operator in some C++ class, for some mixed C++ / ObjC I've been writing. A truely classic C++ mistake!

The code basically did something like this:

MyCppObject = MyCocoaObject; // using a copy-constructor but no assignment function!

Which looks nice and concise, but one that one line, actually three things are done. Copy-constructor, assignment, and destructor. This lead to the ObjC class being released in the destructor, which I had forgot.

Once I was able to track the bug down to that general area where I was using that C++ class, figuring out the answer was obvious. But before then, the bug could have been anywhere in many thousand lines of code. I actually acheived this by using NSAutoReleasePool, which I was suggested not to, but... it did work in narrowing my search down!

I'm sure some will tell me that mixing C++ classes with ObjC classes is generally "not nice", but really I have no choice, because the code I am porting uses C++ classes and I must faithfully replicate them. (it's only a few, thankfully!)

--
http://elfdata.com/plugin/ Industrial strength string processing, made easy.


"All things are logical. Putting free-will in the slot for premises in
a logical system, makes all of life both understandable, and free."

_______________________________________________
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


  • Follow-Ups:
    • Re: Tracked down the over-release bug
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: how to make an NSWindow unmovable...
  • Next by Date: Re: how to make an NSWindow unmovable...
  • Previous by thread: Re: One Solution for storing ordered arrays within Core Data objects
  • Next by thread: Re: Tracked down the over-release bug
  • Index(es):
    • Date
    • Thread