PDA

View Full Version : Xcode in 64 bit mode




reflex
Jan 25, 2008, 04:53 AM
I've noticed that Xcode 3 by default runs as a 32 bit app in Leopard, so I switched that option off and started it as a 64 bit app. Then I opened Activity Monitor to see if it would tell me that it's in 64 bit mode (which it did).

While doing this, I noticed that Xcode used (or reserved) about 35GB of virtual memory (yes, gigabytes). So I put it back in 32 bit mode, and it only used 1GB of virtual memory.

Not that I care much about this difference in practice, but I do wonder why there would be this big a difference between the two. Does anyone have any idea about this?



Cromulent
Jan 25, 2008, 05:09 AM
I've noticed that Xcode 3 by default runs as a 32 bit app in Leopard, so I switched that option off and started it as a 64 bit app. Then I opened Activity Monitor to see if it would tell me that it's in 64 bit mode (which it did).

While doing this, I noticed that Xcode used (or reserved) about 35GB of virtual memory (yes, gigabytes). So I put it back in 32 bit mode, and it only used 1GB of virtual memory.

Not that I care much about this difference in practice, but I do wonder why there would be this big a difference between the two. Does anyone have any idea about this?

Because it needs to load the 64bit versions of all the frameworks it uses. Plus because it is 64bit certain variables are twice the size. Running Xcode in 64bit mode sounds pretty pointless if you ask me. Why would you be needing Xcode to address more than 4GBs or real RAM?

Also virtual memory is meaningless it is what is potentially allocated to an application not necessarily what an application is using.

reflex
Jan 25, 2008, 06:56 AM
I don't intend to run Xcode in 64 bit mode, it was just a little experiment :)

But wouldn't the 32 bit version need to load frameworks as well? In other words, a difference of 34GB seems pretty steep.

Not that I'm worried or anything, just curious.

gnasher729
Jan 25, 2008, 08:12 AM
I don't intend to run Xcode in 64 bit mode, it was just a little experiment :)

But wouldn't the 32 bit version need to load frameworks as well? In other words, a difference of 34GB seems pretty steep.

Not that I'm worried or anything, just curious.

Virtual memory sizes seem to be absolutely meaningless. For example, how much stack space would you give every thread by default? You've got 16 billion gigabyte address space, so you might as well give 1 GB virtual space to each thread; that means you run out of memory once you created 16 billion threads :D Virtual memory costs nothing. So with 34 threads, 34 GB virtual memory is used. Nobody cares (except users who see these huge numbers and get worried for no reason).

gnasher729
Jan 25, 2008, 08:14 AM
Running Xcode in 64bit mode sounds pretty pointless if you ask me. Why would you be needing Xcode to address more than 4GBs or real RAM?

It should be running a bit faster because it has twice as many registers on Intel 64 bit than on Intel 32 bit. But that would only make a difference if the compilers are 64 bit.

reflex
Jan 25, 2008, 08:20 AM
Makes me think I should try to make a 64 bit app that runs out of memory some time :)

Cromulent
Jan 25, 2008, 08:26 AM
Makes me think I should try to make a 64 bit app that runs out of memory some time :)

Well that is not hard to do. Most people are still limited by rather small amounts of RAM.

iSee
Jan 25, 2008, 08:49 AM
malloc(1000000000000000)


Or, for more drama, do it 1K at a time:


while (1)
malloc(1024);


I double-dog dare you to run this on your Mac :eek:

reflex
Jan 25, 2008, 08:49 AM
It depends on the size of the page file, doesn't it?

Catfish_Man
Jan 25, 2008, 08:25 PM
Actually, I'm pretty sure I know at least some of what's happening here.

In 32 bit mode, both the kernel and the application are given a full 32 bits of address space, forcing a flush of the mapping from virtual space to real space (see http://en.wikipedia.org/wiki/Translation_Lookaside_Buffer ) each time the kernel has to do something.

In 64 bit mode, the kernel still gets its 32 bits of address space, and the application then gets everything *after* that.

However, that only explains an additional 4GB or so. Not sure where 35 is coming from. Regardless, in 64 bit mode you've got way more than enough address space to spare.

gnasher729
Jan 26, 2008, 09:35 AM
Well that is not hard to do. Most people are still limited by rather small amounts of RAM.

Actually, the 64 bit software would be limited by the size of your hard drive and your patience. The amount of _fast_ memory that you have is limited by RAM, beyond that it just goes a lot, lot slower. (I know people who used machines with 16 GB of RAM a few years ago for software that took days to get its results; they turned off virtual memory because that made everything about five percent faster, and if the 16 GB wasn't enough, swapping to the hard drive was so slow that it was pointless).

guest7
Oct 18, 2008, 10:15 AM
how can i change the xcode from 32 bit to 64 bit. I am getting a error in running a program :

(5209) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

How can i solve this error..

i am using MAC 10.5 , Xcode 3.0

Please help!

Thanks

Morn
Oct 29, 2008, 03:32 PM
64 bit is a more efficient instruction set that has benefits beyond just memory size.
It's faster. It's a new version of x86 with some of it's worst bottlenecks removed.
However.... this doesn't really help xcode either... as xcode running as 64 bit starts 32bit processes of gcc when compiling. And gcc doesn't seem to benefit from 64 bit either.
But here, some benchmarks on linux, good way to compare 32bit and 64bit.
http://art-blog.no-ip.info/files/amd64vsi386.pdf

Very impressive. Video encoding is 20% faster, Image editing 105% faster, 3D rendering is 56% faster Firefox is 6% faster on javascript and 24% faster on CSS and apache is 40% faster.
I'm quite annoyed at how few apps are out in 64 bit versions.

foidulus
Oct 29, 2008, 03:48 PM
but how do you tell if an application is in 64 bit mode or not?

Just noticed that XCode is one of the few that have 64 bit PPC binaries as well(well, Chess.app does too :p)

Catfish_Man
Oct 29, 2008, 03:50 PM
I can't pinpoint *what* is wrong with that benchmark, but something definitely is. Those are very very abnormal results to get. My guess would be that the 64 bit version of some apps are targeting new processors, since only new processors are 64 bit; that would allow them to use SSE2 and such. That's just a wild guess though, could be totally off the mark.

Morn
Oct 29, 2008, 11:53 PM
I don't think so, some things certainly do see a large benefit. You can see that from this benchmark app with some tests doing 30% better, while on powerpc 64 tending to be slower because it's pretty much the exact same instruction set with just the ability to handle larger numbers, where x86-64 is a whole new x86.
http://www.geekpatrol.ca/2006/09/32-bit-vs-64-bit-performance/

Catfish_Man
Oct 30, 2008, 12:34 AM
30% is on the high side of what I'd expect, but not unreasonable. My own tests have shown 15-20% is a reasonable expectation. >100% though? Something is weird there.