Findings from Linux! Exciting story!
Boring technobabble!
Normal allocation. When I allocate a bitmap of 1,000 x 1,000 pixels and paint them all yellow (to ensure that the lazy library/gfx card really allocates something), VRAM usage goes up by 4 MB. Makes perfect sense, it's 1,000,000 pixels with 32-bit colors.
Maybe the card allocates chunks only powers of two and it really allocates 1,024 x 1,024 pixels, but such details don't matter. The 4 MB is perfectly what we would expect. I've measured this with
nvidia-msi, command-line tool from my Linux nvidia driver, but an even broader ballpark guess was available in Lix if you check "show FPS" in the options.
RAM usage doesn't increase when I allocate such VRAM bitmaps, at least as long as the graphics card has free VRAM. I can have 100 MB in VRAM and RAM would merely increase by a couple kB, too little to dent any estimate.
Swapping. When you allocate VRAM and the graphics card grows full, the newer allocations still go through without error -- but the graphics card will swap some bitmaps from VRAM into RAM.
We remember how the bitmap of 1,000 x 1,000 pixels occupied 4 MB of VRAM. Now, when the graphics card swaps VRAM into RAM, suddenly such a swapped bitmap occupies 8 MB.
This still doesn't sum to the 2 GB that I observed on Windows. Certainly, the 10 savestates during networking games aren't 100 MB to 200 MB each -- the biggest ingredients are a physics matrix, a land bitmap, and the arrays of lixes. The swapped land is probably the fattest ingredient.
Still, let's keep in mind for now that the graphics card can swap, and the bitmaps surely won't become any leaner or faster in the RAM.
Deallocation. Allegro VRAM bitmaps are manually managed; I have to call destroy explicitly on them, but then the VRAM is immediately available again. I'm reasonably sure that I have no VRAM leaks, but certainly allocate several fat bitmaps.
Leftovers from un-swapping. Now comes the fun part: A freshly started Lix occupies maybe 50 MB in RAM and 11 MB in VRAM. I begin allocating VRAM test bitmaps. Eventually these get swapped to RAM, as descibed above. Let's continue allocating VRAM until 2 GB of RAM is filled with swapped bitmaps.
Now, we deallocate these test bitmaps one-by-one, until none of them is left. The VRAM of Lix has dropped to around 5 MB, slightly less than the 11 MB from a fresh start. But we still have 1.5 GB of RAM filled! This leftover swap-RAM, or whatever it is, doesn't seem to be freed anytime soon. It's not part of the garbage-collected D heap -- I can call the garbage collection manually as often as I want, with no effect.
Looks like it's private memory allocated by the video driver that is called via Allegro inside Lix. In
top, these 1.5 GB are still ascribed to Lix.
-- Simon