Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between compiling for i386 vs x86_64 in Xcode?

What are the differences between compiling a Mac app in Xcode with the Active Architecture set to i386 vs x86_64 (chosen in the drop down at the top left of the main window)? In the Build settings for the project, the Architecture options are Standard (32/64-bit Universal), 32-bit Universal, and 64-bit Intel. Practically, what do these mean and how does one decide?

Assume one is targeting OS X 10.5 and above. I see in the Activity Monitor that compiling for x86_64 results in an app that uses more memory than one compiled for i386. What is the advantage? I know 64-bit is "the future", but given the higher memory usage, would it make sense to choose 32-bit ever?

like image 321
sam Avatar asked Jul 16 '10 16:07

sam


1 Answers

32/64-bit Universal -- i386, x86_64, ppc

32-bit Universal -- i386, ppc

64-bit Intel -- 64 bit Intel only

ppc64 is no longer supported.


x86_64 binaries are faster for a number of reasons; faster ABI, more registers, on many (most & all new machines) machines the kernel is 64 bit & kernel calls are faster, etc.etc.etc...

While 64 bit has a bit of memory overhead directly related, generally, to how pointer heavy your app's data structures are, keep in mind that 32 bit applications drag in the 32 bit versions of all frameworks. If yours is the only 32 bit app on the system, it is going to incur a massive amount of overhead compare to the 64 bit version.

64 bit apps also enjoy the latest and greatest Objective-C ABI; synthesized ivars, non-fragile ivars, unified C++/ObjC exceptions, zero-cost @try blocks etc... and there are a number of optimizations that are only possible in 64 bit, too.

like image 92
bbum Avatar answered Nov 14 '22 23:11

bbum