Increase Memory on 64bit Machines

Leoreth

Blue Period
Moderator
Joined
Aug 23, 2009
Messages
36,963
Location
東京藝術大学
While discussing the implementation of the graphical paging feature with some people over at the C2C forum they made me aware of a tool that can increase the amount of available memory for 32bit executables on 64bit machines from 2 GB to (almost) 4 GB.

Some background: Civ4 is implemented as a 32 bit application which limits the amount of available RAM to 2 GB, even though 64 bit machines can provide much more than that (which your computer is likely to have).

So if you have a 64bit operating system, you can download this tool and execute it on the Civ4BeyondSword.exe file in your BeyondTheSword folder to increase the available memory to 4 GB (this applies to all BtS games and mods).

If you are running a 32bit OS, this tool unfortunately cannot help you.

I really recommend doing this if you have problems with performance.
 
And while reading through a random thread a few days ago, I stumbled upon this, which is said to vastly increase the inbetween turn time speed (among other things, I guess?). I haven't tried it yet, but it sounds interesting.
 
Looks interesting, I will give it a try.
 
Wow, just tried it for myself and the difference between the old load times and the new are staggering.
I can't give an accurate estimate by how much faster it feels, but it's like somewhere between 20-35% faster on everything, turn times, load turns, loading saves, etc.
 
Wow, just tried it for myself and the difference between the old load times and the new are staggering.
I can't give an accurate estimate by how much faster it feels, but it's like somewhere between 20-35% faster on everything, turn times, load turns, loading saves, etc.

Ramdisk or the memory usage change? Anyway, it sounds great. I will test it.

Leoreth, if it works, why not put it in the download thread?
 
Because it's an exe. I know you probably trust me, but some additional legitimacy from the actual source doesn't hurt.
 
I'll have to try this out soon. I keep getting bummed out playing the Canadians, because the turns are ridiculously long, and sometimes it even freezes somewhere in the 19th century before I can even play. I'm 64bit and have an excellent computer.
 
And while reading through a random thread a few days ago, I stumbled upon this, which is said to vastly increase the inbetween turn time (among other things, I guess?). I haven't tried it yet, but it sounds interesting.

Why would you want to increase the turn time?
 
I like you. :p
 
I did a quick speed test with the exe. A 600 AD French game took 55 seconds to load normally, and 50.5 with the exe. That is an improvement of about 8% less load time, although I imagine it would have been more significant in the late game (as the late game has more civs and stuff and should require way more memory). I couldn't test it with the 1700 AD scenario because now that the bts exe is patched I have no idea how to un-patch it to make a comparison.

On the other hand, RAMDISK seems to have a lot of potential. I installed it and created a 4 GB RAMDISK (the largest possible in the freeware version), however after copying vanilla Civ 4 and BTS I am unable to start BTS as it always gives an error along the lines of "failed to initialize python". Anyone managed to get it working? If somebody helps me out I will post a speed comparison pre and post RAMDISK.
 
Haven't tested Ramdisk yet, I'll try to write up a guide for setting it up for BtS in case I manage to figure it out at some point.
 
I did a quick speed test with the exe. A 600 AD French game took 55 seconds to load normally, and 50.5 with the exe. That is an improvement of about 8% less load time, although I imagine it would have been more significant in the late game (as the late game has more civs and stuff and should require way more memory). I couldn't test it with the 1700 AD scenario because now that the bts exe is patched I have no idea how to un-patch it to make a comparison.

On the other hand, RAMDISK seems to have a lot of potential. I installed it and created a 4 GB RAMDISK (the largest possible in the freeware version), however after copying vanilla Civ 4 and BTS I am unable to start BTS as it always gives an error along the lines of "failed to initialize python". Anyone managed to get it working? If somebody helps me out I will post a speed comparison pre and post RAMDISK.

From what i've read online it sounds like 4 GB alone may not be enough to load a game onto it and function.
 
I used this and it doesn't seem to work. Do I have to do it on each seperate mod? I do run a 64 bit OS and I have 4gb so that isn't the issue. Thoughts?
 
You have to do it on the BtS EXE.
 
I did. Did nothing.
 
I just came across this thread and I have to say you shouldn't hide it that well. It really should be in some sort of "public library" with useful information, which applies to all mods.

I haven't tested it yet, but theoretical knowledge tells me this:

Expanding RAM address space:
I have known for ages that 32 bit can't access more than 4 GB RAM, which supposedly should be a prime motivator for moving to 64 bit systems. Don't listen to the talk about performance because some early 64 bit CPUs ran faster in 32 bit mode.

However I have always believed that 32 bit applications can use 4 GB when used on a 64 bit system. I have never heard of a 2 GB cap, though based on the description, it seems like a fair decision to add on 32 bit systems, meaning it's a relic, which we no longer need. I kind of suspect this to be a windows issue and that using 32 bit applications on mac or linux will not have this problem.

From a first glance, the only effect would be to avoid a crash when reaching 2 GB usage, which I guess is still the primary goal. However I find it plausible that it might improve performance in some cases. This would be due to memory fragmentation. If the game has twice the memory, it can spread out and can allocate twice as much memory before congestion issues appears. This is kind of like HD fragmentation. If you use 80% of a HD, it will be fragmented and slow down while using just 30% will counter most of this problem, even if you have the same amount of data on equally fast HDs.

RAM disk:
I have been using these on and off since the late 90s. They are great when used right, but used incorrectly you will not really gain anything.

Using memory has both higher bandwidth and lower latency. This means it will be insanely fast, but only if the disk access is the bottleneck. I once placed Neverwinter Nights 2: Storm of Zehir expansion in a RAM disk due to game breaking loading times. Turned out that disk access wasn't the issue, but rather what the CPU did to the loaded data, meaning the loading time depends on CPU speed rather than disk speed. NW2:SoZ was slammed in reviews for way to long loading screens, which often interrupts the gameplay, but it's actually pretty decent on modern hardware.

The improvement of using RAM disk increases the slower the HD is. SSD owners will see less of an effect and copying from a DVD to RAM disk will make a world of difference, mainly due to seek speed improvements.

Expected effects on Civ4: (any version)
Clearly expanding RAM allows bigger mods. It may increase performance in big games as well. RAM disk on the other hand will likely have less of an effect. Starting the game will likely improve, but the important part about performance is how long you have to wait for the AI. The AI doesn't use the disk at all, meaning I wouldn't expect any difference here whatsoever. It's also important to note that a not insignificant part of the loading time is the windows overhead from opening and closing a file, which will not be improved.

Autosaves have been mentioned as being faster and while it's most likely true, do you really want to save to a location, which is gone if your computer crashes? Savegames is likely the most important thing to store on a permanent disk. RAM disks should be for temporal files only.
 
You're completely right, this should probably go into the tutorials section at least (I'd prefer the wiki but afaik it's still write locked for some reason). I also only learned about it through word of mouth and basically rushed to share it with my players because I had acute issues with memory related crashes around that time (ultimate cause was the overreliance on FPKs like you described in the thread that likely led you here) so I unfortunately never considered how useful this information is for everyone.
 
Top Bottom