• 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: cocoa app using external c++ code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cocoa app using external c++ code


  • Subject: Re: cocoa app using external c++ code
  • From: Paul Forgey <email@hidden>
  • Date: Sat, 1 Apr 2006 12:13:43 -0800

These are c++ class instances, not objective C class instances.

On Apr 1, 2006, at 6:39 AM, Alan Smith wrote:

I'm not absolutely sure about this, but here's a thought. I believe it has something to do with pointers, uh duh :). You allocate a pointer and then try to destroy it. Since it's a pointer you're actually attempting to destroy the class it points to, or something like that. That is the basic idea and I'm afraid I didn't do a very good job of explaining it. I would not dealloc that pointer but just leave it alone and watch the memory usage of your program, hopefully you don't need to find a way to deallocate it. Oh, one other thing. From past experience, say you make a NSTask like this,
NSTask *task;
but not like this,
NSTask *task = [[NSTask alloc] init];
in the second line you have a allocated NSTask but not in the first. If you do it the first way and then try to release it you should get a complaint of some kind, most likely your program will crash.


I hope that helps, Alan

On 4/1/06, Paul Forgey <email@hidden> wrote: I have a cocoa app written using objc++ using external c++ code. Any
external classes allocated via new crash the heap if I delete them.
If I enable Guard Malloc I get this message:


GuardMalloc[Administration Console-1883]: Tried to free pointer at
0xb161d6cc which is not currently a pointer to a malloc buffer.
GuardMalloc[Administration Console-1883]: Explicitly trapping into
debugger!!!

Which pretty much agrees with what malloc_printf complains about with
it turned off.  I know for a fact I am not disturbing the state of
the heap, as I can cause this to happen first thing in main before
running any actual code:

// main.mm

int main (int argc, char *argv[])
{
   Otherclass *x = new Otherclass ();
   delete x; // CRASH
   ..
}

What's going on??  I can't find any compiler options XCode is setting
that would disturb alignment or anything.  In fact my working C++
command line programs all see the same sizes and layouts the cocoa
app does.




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list ( email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden





--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >Re: cocoa app using external c++ code (From: "Alan Smith" <email@hidden>)

  • Prev by Date: Re: Calling .jar routines from a C program
  • Next by Date: Re: cocoa app using external c++ code
  • Previous by thread: Re: cocoa app using external c++ code
  • Next by thread: Re: cocoa app using external c++ code
  • Index(es):
    • Date
    • Thread