64-bit: Why is it so important?

Whether Software Developer is in your job description or not, you should understand the difference between 32-bit and 64-bit. Read on for a clear answer.

Xojo 2017 Release 1 adds support debugging 64-bit apps. Why do you need to be able to build and debug 64-bit applications? The short answer is 2 reasons: Memory and Progress. The long answer is, well, long so keep reading. Before I get into the nitty-gritty, you should know that for the vast majority of Xojo users, the only thing you have to do to build 64-bit versions of your apps is select 64-bit from a menu and click the Build button. Now for the details.

Most things an app does consume memory. Open a window, display a webpage, use a file, create a variable to store a value for a moment and you are using some memory. When you close the window, the page, or when the variable goes out of scope, that memory is released. Behind the scenes, the Xojo framework keeps track of all this memory your app is using. It makes sure it sticks around while you need it and goes away when you are done. When a value it stored in memory, it’s stored at a particular location. That location has an address which is basically the starting point of the first byte of memory in which the data is stored.

In a 32-bit application, the addresses themselves are stored in integers that are 32 bits in size. Since there are only so many combinations of values you can store in 32 bits, the total number of address values is 4,294,967,294. As a result, the maximum amount of memory a 32-bit application theoretically can use is about 4GB. The real number is closer to 3.7GB and that varies from one operating system to another. For most applications that much memory is more than enough. However, for some applications, it’s not even close. Imagine you are creating an application that will deal with lots of large photos or video, you can easily reach the point where you need more memory to display more pictures or video but you’ve hit your 32-bit app’s memory ceiling.

As you have probably already guessed, 64-bit applications store memory addresses in integers that are 64 bits in size. You might think that 64 bits means twice as many addresses and thus double the amount of memory that an app can use. It’s safe to say that nothing could be further from the truth. A 64-bit integer is itself twice the size of a 32-bit integer. However, with all those extra bits, the number of values goes up by several orders of magnitude. The largest 64-bit number is 18,446,744,073,709,551,615. If you’re not sure how to even say such a number, it’s eighteen quintillion four hundred forty-six quadrillion seven hundred forty-four trillion seventy-three billion seven hundred nine million five hundred fifty-one thousand six hundred and fifteen. That’s a big, big number. It’s so big in fact that if I turn my iPhone sideways so I can use the scientific calculator, I can’t even enter a number this big. It stops when I get to 16th digit.

I think I’m on solid ground when I say that it’s not really practical to build a computer with that much memory in it but let’s throw caution to the wind and see what would be involved.

I went to Crucial.com and found that the biggest single-stick memory module they sell is 32GB for $352.

We are going to need a lot of them. In fact, we are going to need 575,000,000 of them at a cost of $200 billion dollars. That’s 50% more than the United States spends every year to pay the salaries of all 2.2 million military personnel. Of course, I’m sure if I placed such an order I could get a really terrific discount but still, we are talking about billions of dollars here. Next, we need to create a something with enough space in it to hold 575,000,000 of these memory modules. They are 5.25 inches long and 1.1 inches tall. Put them end to end and you’d have a line of 32GB memory modules 47,644 miles long, almost enough to reach completely around the circumference of the Earth twice. Of course we aren’t going to put them end to end but how big of a box would we need to hold all this memory? I did the math. Let’s start with something really big. How about a box the size of a tractor trailer? Nope, too small. OK, what about a box the size of a typical two-story house? Nope.

In fact, you’d need a box 100 feet long by 100 feet deep and 130 feet tall (about the size of a typical office building) to hold 575,000,000 of our 32GB memory modules. That’s one big computer! You won’t have a smartphone with that much memory anytime soon. The cost of the box itself would of course be trivial compared to the cost of the memory. Power would also be a problem. At 1.5 volts per module, you’d need to generate about 862,000,000 volts. Something like the Hoover Dam ought to do it. For the truly geeky out there, yes there’s almost certainly a more efficient way to create this ridiculous amount of memory, but you get the idea.

“18,446,744,073,709,551K ought to be enough for anybody.” – Geoff Perlman

Needless to say, the biggest advantage to building 64-bit apps is that your apps will only run out of memory when there’s no more memory left to access in your computer no matter how much memory it has in it. This will likely continue to be true even for your grandchildren’s grandchildren but don’t quote me on that.

By now you have probably forgotten the second benefit of building 64-bit applications – Progress. As operating systems continue to improve, more and more of the system calls the Xojo framework must use to do the voodoo it does so well will be 64-bit only. When we start using these, your projects that use the Xojo functions that use these calls behind the scenes will need to be built as 64-bit applications. Fortunately, as I said earlier, we have done most of the heavy lifting for you. Only a small portion of you will need to update some of your code before you can compile for 64 bit and you know who you are.

Updating Xojo to support building 64-bit applications has taken reviewing hundreds of thousands of lines of code and several man years. The good news for you is that with a mouse click your apps will be able to use all the memory available and be ready for the future. No office building-sized computer required.

