Indeed, it is still likely to be an exe limitation, where e.g. a 1024 KB memory buffer is exceeded for light effects or something along that line. These smaller RAM buffers that can be exceeded are mostly handled by the exe as they are typically related to sound and graphics. If MAF is caused by the dll then it will most likely be a MAF where one runs out of RAM (~2.8 GB) because otherwise the exe wouldn't post a MAF message, but the game would CTD in the dll due to unexpected behavior from the bad memory handling there and would not post any message at all unless attached to VS or something.
In late game maybe, but the game MAFs also if there is enough RAM left. So with 100 civs you will only start with 100kb more RAM usage or so. You can see that by causing the plot error in WB then the game will MAF but it has many RAM left.
So the future is to save more stuff to the HDD, not to memory. That will give a lot more free memory and the usage will be very low.
Same like it is done now with the graphics paging, only load the units to the memory in the region where you are currently viewing, maybe that can be done.
@Toffer90 Also if the exe still CTD at 2.8 GB read this, looks like the dll is not LAA flagged correctly then? Maybe that can be improved, read FAQs on this page:
wiki.tesnexus.com
FAQs
"Do you need to LAA patch DLLs? The answer is a qualified 'yes'. See the Wikipedia articles
Dynamic-link library and
Virtual Memory for the full background, but the relevant point is this:
"With the introduction of 32-bit libraries in Windows 95 every [DLL] process runs in its own address space." [This would be
physical address space. As far as the application is concerned, the DLL is loaded into it's virtual address space.]
DLLs share the same file format as an EXE. As with EXEs, DLLs can contain code, data, and resources..."
Looks to me if it still CTD at 2.8 GB that it is not set correctly to use the full 4 GB currently. Maybe because the dll is not LAA patched.
Also maybe you want to test that tool on the exe if it will help to free full 4 GB:
ntcore.com
I want to see if it will CTD later with my 24 GB graphics card now. But hard to go there with the memory usage updates now.
Next possibility - Read here:
https://accu.org/journals/overload/21/113/oldwood_1875/
(Maybe that can be adapted to the mod code)
Page-files
The hard disk can also act as a temporary store for memory pages that are not currently in use. This is called virtual memory because it can only be used for page storage – the pages still have to be present in physical memory to be accessed.
This total size of all paging files defines the virtual memory limit for the entire machine; this can be smaller or larger than the per-process 4GB limit.
Page-file backed shared memory
There is another way to access all that extra memory using the existing Windows APIs in a manner similar to the AWE mechanism, but without many of its limitations: Shared Memory. Apart from not needing any extra privileges the memory allocated can also be paged which is useful for overcoming transient spikes or exploiting the paging algorithm already provided by the OS.
Allocating shared memory under Windows is the job of the same API used for Memory Mapped Files. In essence what you are mapping is a portion of a file, though not an application defined file but a part of the system’s page-file. This is achieved by passing INVALID_HANDLE_VALUE instead of a real file handle to CreateFileMapping() . Listing 1 creates a shared segment of 1MB.
const size_t size = 1024 * 1024;
HANDLE mapping = CreateFileMapping(INVALID_HANDLE_VALUE,
NULL, PAGE_READWRITE,
0u, size, NULL);
if (mapping == NULL)
throw std::runtime_error
("Failed to create segment");
|