• 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: NSPoint. The results. Look at that, Georg!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPoint. The results. Look at that, Georg!


  • Subject: Re: NSPoint. The results. Look at that, Georg!
  • From: Pascal Goguey <email@hidden>
  • Date: Tue, 4 Mar 2003 00:49:12 +0900

Hello!


On Monday, Mar 3, 2003, at 23:59 Asia/Tokyo, Pete Yandell wrote:

[...]

Thanks for your very detailed reply. I learned a lot!
I would like to thank Nathan and Sherm as well.

At a minimum, an objective-C object is going to have 4 bytes of
overhead on top of the size of the equivalent struct. This is to hold
the "isa" pointer which determines the class of the object. Adding
4 bytes to an 8 byte object is, of course, substantial overhead.

Yes, I just discovered that a few minutes ago.
Apparently _ALL_ objects have to inherit from NSObject, and
sizeof(NSObject) returns 4 bytes.

Try adding a virtual method to your C++ BPoint class and you'll
find that it'll grow 4 bytes as well. Now all objects of that class
need a pointer to the virtual function table.


The conclusion:

For simple data structures the overhead of objective-C objects
compared to simple C structs is quite large.

For larger and more complex objects, of course, the overhead
of objective-C is more than worth it for the advantages of
dynamic method dispatching, dynamic typing, etc.

I think the design decision to keep points, rectangles, etc.
as structs was a very sensible one.

Yes, I was also sure convinced that there was a good reason.
But the replies until now didn't give any explanation...
Anyway, your reply provided good runtime figures and
it was very informative.

Pascal
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSPoint. The results. Look at that, Georg!
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: automatic web updates
  • Next by Date: Re: NSPoint. The results. Look at that, Georg!
  • Previous by thread: NSPoint. The results. Look at that, Georg!
  • Next by thread: Re: NSPoint. The results. Look at that, Georg!
  • Index(es):
    • Date
    • Thread