Memory usage targeting x86 vs x64

Hi !

I have a strange issue with memory when I switch from x86 taget to x64.
Most of time the x86 build uses from 80 to 100 MB ram. If I switch to x64 the memory usage jumps from 900 to 1200 MB ram. I know 64 bits uses more ram than 32 bits, but 10x seems insane…

I have used the VS 2022 memory profiler to understand what’s appening but the things going stranger :

  • The graph part shows up to 1200 MB ram
  • The stack indicates something like 33 MB ram

The compressed content is somthing like 75 MB on disk and the orignal content is somthing like 230 MB on disk (mostly pngs)

Can you please give me some advices to understant what’s happening ? It seems that next monogame release will be x64 only and I’m afraid my small game would require gigabytes ram to run properly…

Thanks

Yeah but did you compile in Release mode?

Hi !

Yes. I tried many combinations.

I tested this on my own game (published with win-64 and win-86 targets), and the difference was, like, 50 vs 80 MB. Maybe it’s something specific to your game/machine. And even if so, an extra gig doesn’t really matter nowadays.

It matters for me :slight_smile:

I tried with a fresh project. Just loading assets.
x86

  • Empty project → 20.7 MB
  • Full asset (956 MB on disk) → 51.4 MB

x64

  • Empty project x64 → 24.2 MB
  • Full asset (956 MB on disk) → 1068.8 MB

It’s like there was a memory saving option that doesn’t works with 64 bits.
Maybe my hardware is not enable to build properly a x64 projet…

That is asinine

That is the reality, my boy. Of course it would be nicer if that wasn’t the case. But I am personally way more concerned about the game itself and its performance than how much RAM it consumes. You can pretty much assume you’ve got infinite RAM unless you’re making Minecraft or something REALLY heavy.

It’s a small game, I can imagine having a normal game using 10x more RAM. There is clearly something wrong with my code, my hardware, my image format (maybe I should try the power of two) or something else.

I continue my tests with fresh project, dummy content on a different PC.

Your results do not mean everything takes 10x as much ram. Only that there is an additional overhead of… something.

One posibility is that the garbage collector on net6/x64 is more flexible in managing system memory.

Do a GC.Collect(), on each update and also after each Content.Load<>(). Check if that affected the allocated memory. (Do not keep those changes in production).

Run additional third applications that reserves a lot of memory and watch if your app returned the memory to the system.

What type of card do you have ?
Does it have dedicated vram or it’s embedded with shared system memory?
Normally, if those 900Mb are mostly textures & 3dmodels they will get loaded on the gpu.
On the cpu you will see only the intermediated buffers/pools that are used to load those assets.

Hi !

GC.Collect() doesn’t change anything.

I use a GeForce GTX 850M, but I have to force windows to run the game on it. The defaut GPU is an Intel HD Graphics 4600.

If I force the GeForce the globale memory usage (shown in VS2022) drop from 1.1GB to 960MB.
Windows shows only 139MB, I suppose the memory “goes” in the nvidia dedicated memory…

Power of two image resolution doesn’t changes anything.

Today I tried on another laptop without dedicated GPU, results are more close between 32 / 64 bit builds.

Tomorow I try with a GT 1030 on another machine.