Question: Can I save RAM usage if I use static leader head?

mediv01

Chieftain
Joined
Nov 10, 2022
Messages
30
Hello guys, here's a question I want to consult: If I replace the leader's dynamic lead head with a static image, will it reduce memory usage and time to pass turns? Thanks a lot !
 
Last edited:
It will obviously save memory, but the question is if it really matter. Not only is the question how much memory it will take up, another question is if the game is wise enough to only load the one currently on the screen rather than keeping all in memory at the same time. I don't actually know the answer to that. I remember something about movies being loaded into memory when displayed rather than being kept in memory at all time, but I'm not sure about leader heads.

As for turn pass time, that is purely AI performance. Graphics won't affect this as the graphics engine even freezes during the AI turn. To shorten that wait, there is nothing to do other than code optimization and/or cache of frequently called functions.
 
Hello guys, here's a question I want to consult: If I replace the leader's dynamic lead head with a static image, will it reduce memory usage and time to pass turns? Thanks a lot !
Reduction of (GPU) Memory Usage: Yes, but that is only an issue for mods that are extremely overloaded with graphics.
Improvement of (CPU) Performance: No, the graphics have almost no impact on the performance related to turn times.

In other words:
Your mod may load a bit faster when you start the game. And if your mod is heavily overloaded with graphics, it may also crash less often if you remove some - especially if you accidently have bugged animations.
But considering the turn times which is mostly related to CPU performance it should have no impact as that time results about 95%+ from AI related logic. (The rest is some "doTurn" checks and calculations).

Personal opinion:
Do what you find most aesthetically pleasing and what is the least effort. If you have already have good 3D quality leaderheads I would keep them.
If you plan on implementing 300+ leaders, maybe it is worth going for 2D though, as it will be much less effort and probably also less risk to run into bugged animations.

Edit:
If you really want to optimize ingame performance, you need to primarily optimize the DLL logic.
Also having too much logic in Python (which is much less performant than DLL) may also be an issue.

The limitation in this game is usually not the GPU. Unless you have a very untidy mod that really overdoes it with the amount and quality of graphics. But then you will most likely run into crashes.
The real limitation in this game is the CPU as it is an old 32Bit application and originally it was limited to one core only. (Implementing multi-threading is possible though if you are a skilled programmer.)

-----

So yeah, I can confirm what @Nightinggale already said. :thumbsup:
(Just adding that broken animations are also a risk for crashes.)
 
Last edited:
I don't actually know the answer to that. I remember something about movies being loaded into memory when displayed rather than being kept in memory at all time, but I'm not sure about leader heads.
As far as I know each graphic file that is touched is loaded into memory and then kept there for a while. (After that time it is dumped from memory again though unless touched again.)
So if you have endless amounts of Terrain Features, Improvements, Units, City Sets, Leaders ... and they are all currently in the game ... quite a lot of stuff may get loaded into memory.

-----------

So yes, to my knowledge graphics are only loaded when needed / used. But they will stay in memory also for some time - and as some turns in endgame take quite long, that could also be quite long.
When you restart the game, all that memory will be freed of course again. Thus exiting the game after a while and loading a savegame may indeed reduce the risks of bugs and crashes.

------------

I cannot give you exact numbers, but it was measured several years ago that the used storage in memory was building up over time (turns ingame), and it seemed to be related to graphics displayed ingame.
Usually it peaked at some point however and more or less stayed there with minimum fluctuations ... after restart and reload memory was freed again and you could see the buildup start a new.

But these measurements were made about 10+ years ago ... and a lot has changed related to hardware of course ... and I doubt that memory usage really still is a big issue related to crashes today.
It was / is much much more likely that a mod will crash due to a bug in the DLL logic ... e.g. "Null Pointer Exception" or "Division by 0" or "endless loop" or ....
 
Last edited:
From my experience with modding units and leaderheads, the game needs to be restarted to make changes in unit files appear, while for leaderheads the changes already apply when the leader it displayed anew. So, I would guess that the game loads all unit graphics into memory when started, while leaderheads are loaded when needed and then removed from memory again.
 
If your mod includes alot of art assets packed into fpk archives that might cause your memory issues.

Because of the way the exe handles the data contained in the fpk's the usable memory is reduced at least by the combined size of the files inside the fpk's.

1GB of files packaged into fpk's equals 1GB less ram available to the game at runtime. It's probably more because there's some overhead.

The downside of not using fpk archives is that the game takes longer to startup when it has to scan through thousands of files.
 
Last edited:
Top Bottom