Modding talk:Player Guide/Troubleshooting

From Stardew Valley Wiki
Jump to navigation Jump to search
This talk page is for discussing Modding:Player Guide/Troubleshooting.
  • Sign and date your posts by typing four tildes (~~~~).
  • Put new text below old text.
  • Be polite.
  • Assume good faith.
  • Don't delete discussions.

Wrong explanation on 32-bit memory space

This sentence in particular:

(All 32-bit programs on your computer also need to share that 3GB block, so the game may have access to much less than 3GB.)

There's a bit of nuance that makes this sentence somewhat technically incorrect.

  • On 32-bit Windows, this is true, but only if you have increased the memory space for 'userspace' processes (by using /3GB parameter or increaseuserva parameter).
  • On 'standard' 32-bit Windows, the available block size for user processes is only 2 GiB, and yes it's shared between other programs (all 32-bit, of course, because we're running on 32-bit Windows)
  • On 64-bit Windows, this is completely false. Each and every 32-bit program has their own 4 GiB "addressable memory space", totally separate from each other (although, as before, only 2 GiB will be usable unless the program was compiled with a certain flag. As long as you have enough memory in your computer, and no misbehaving programs fully consume their memory space, then the game will be able to see -- and use -- nearly all its (2 GiB) memory space.

Pepoluan (talk) 14:15, 28 May 2021 (UTC)

We only care about 64-bit Windows here, since players on 32-bit Windows can't use this. Both Stardew Valley.exe and StardewModdingAPI.exe are marked LARGEADDRESSAWARE, so in theory they should have access to a full 4GB of memory space. It'd be great to provide a more accurate explanation on the page, but do you know why players often report OutOfMemoryException errors with 1–3GB memory used despite having plenty of available system memory? For example, here's an OutOfMemoryException crash on a system with 32GB of memory with 1.2GB in use by the game. —Pathoschild (talk) 15:26, 29 May 2021 (UTC)
I would say that it isn't true in _any_ situation.
  • On 32-bit Windows, it isn't true as far as I have ever been aware. increaseuserva specifies that you want processes to have 3 GiB of virtual address space available instead of the default 2 GiB. The default was specified as many much older programs assumed that logical addresses wouldn't be larger than that and would fail.
  • Process logical address space is not shared between processes. Physical memory is, but that is mapped to processes (into their logical address space). Even 32-bit NT can address more than 4 GiB of physical RAM via PAE. If you have two 32-bit processes, they do not share a 2 GiB logical address space. Or a 3 GiB logical address space. They have their own logical address spaces. They compete for physical memory, but that's true of any system.
  • On 64-bit Windows, obviously the same applies. Except that if a process is flagged as LARGEADDRESSAWARE, it gets access to the full 4 GiB address space instead of 3, as the kernel does not need to be mapped within the 4 GiB address space (during an interrupt, the processor switches back to long mode and the kernel can access its own memory which is mapped outside of what the process is aware of).
I mean, unless we're talking about Windows 9x. Those could and would operate weirdly... but Windows NT has never operated this way.
The reason players still see OutOfMemoryException is that the process is exhausting its logical address space. Simple as that. You can exhaust it without ever committing physical pages.
Ameisen (talk) 23:22, 10 October 2021 (UTC)
I rewrote that part to be vague instead: "That means your game ran out of available memory mid-session, which can happen even if your computer has plenty of physical memory available due to 32-bit limitations." It'll be a moot point soon, since all modded players will have 64-bit in Stardew Valley 1.5.5. —Pathoschild (talk) 23:32, 10 October 2021 (UTC)