Xcode in 64 bit mode

Discussion in 'Mac Programming' started by reflex, Jan 25, 2008.

  1. macrumors 6502a

    Joined:
    May 19, 2002
    #1
    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?
     
  2. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    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.
     
  3. thread starter macrumors 6502a

    Joined:
    May 19, 2002
    #3
    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.
     
  4. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #4
    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).
     
  5. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #5
    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.
     
  6. thread starter macrumors 6502a

    Joined:
    May 19, 2002
    #6
    Makes me think I should try to make a 64 bit app that runs out of memory some time :)
     
  7. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #7
    Well that is not hard to do. Most people are still limited by rather small amounts of RAM.
     
  8. macrumors 68040

    iSee

    Joined:
    Oct 25, 2004
    #8
    Code:
        malloc(1000000000000000)
    
    Or, for more drama, do it 1K at a time:

    Code:
    while (1)
        malloc(1024);
    
    I double-dog dare you to run this on your Mac :eek:
     
  9. thread starter macrumors 6502a

    Joined:
    May 19, 2002
    #9
    It depends on the size of the page file, doesn't it?
     
  10. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #10
    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.
     
  11. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #11
    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).
     
  12. macrumors newbie

    Joined:
    Oct 18, 2008
    #12
    Urgent Query

    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
     
  13. macrumors 6502

    Joined:
    Oct 26, 2005
    #13
    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.
     
  14. macrumors 6502a

    Joined:
    Jan 15, 2007
    #14
    Stupid question

    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)
     
  15. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #15
    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.
     
  16. macrumors 6502

    Joined:
    Oct 26, 2005
    #16
    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/
     
  17. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #17
    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.
     

Share This Page