Welcome to the LargePageInjectorMods! This mod significantly enhances Stellaris's or other Games/Applications performance by optimizing its memory management.
Support for other games/application is highly expermimental and untested and may not work.
A memory allocator is a software component responsible for managing the allocation and deallocation of memory during a program's execution. Efficient memory allocation is crucial in games like Stellaris or Factorio, as it can lead to smoother performance. By using a more efficient allocator, such as the one introduced in this mod, the game's performance can be noticeably improved.
mimalloc
, developed by Microsoft, is an advanced memory allocator that generally outperforms standard allocators in speed and memory fragmentation efficiency. By integrating mimalloc
into Stellaris, Factorio or other Games/Applications through this mod, the game benefits from faster memory operations, enhancing overall performance. mimalloc GitHub
DLL (Dynamic Link Library) injection is a method used to run code within the address space of another process by forcing it to load a dynamic-link library. In the LargePageInjectorMods, we utilize DLL injection to seamlessly replace Stellaris's default memory allocator with mimalloc
, without the need for modifications to the game's executable files.
The LargePageInjectorMods can provide a substantial performance boost (Performance only tested for Stellaris):
Standard Performance Increase: Small performance increase of 4-5%, could be completly negligible or significantly larger depending on circumstances.
Enhanced Performance with Large Pages: When enabled with Large Pages, the mod can deliver a 5-80%+ Performance Increase.
Please note that the performance increase can varry dratically based on your save (Performanc increase should be bigger the later in the game you are and the heavier the save is), your hardware(generally there bigger performacne gains on weaker hardware), what mods your using and more. Your performance gains may me significantly smaller or larger then anything mentioned above. Somone with weaker hardware did report getting an 80% Performance increase so large gains are not impossible.
stellaris.exe
, factorio.exe
or the games executable in general is located).To enhance performance further by enabling Large Pages, follow these steps:
First, grant your Windows user the LockPagesInMemory
privilege:
This privilege is necessary for enabling Large Pages and can be granted through the Local Security Policy editor (secpol
):
Win + R
, type secpol.msc
, and press Enter.Security Settings
-> Local Policies
-> User Rights Assignment
.For more detailed instructions, refer to the Microsoft documentation.
Set the MIMALLOC_RESERVE_HUGE_OS_PAGES
variable in LargePageInjectormods.toml to 1 or higher (default is 8). This value represents the GB of Large Pages to reserve, ideally more than the RAM typically used by the Game/Application your trying to run.
Note: Insufficient continuous RAM can lead to memory fragmentation issues.
This mod uses the following third-party libraries:
This mod has been tested for the list but might also work for other games provided they are 64 bit native apllicatiions and use the same C Runtime Library. Reports/Suggestion on Games/Application you have succefully used this on, are welcome and I might add them to the supported list.
Please don't report any Issues related to unsupored application that don't work unless you have a pull requests that makes them work.
It should be compatible with all other mods for the supported games. If you encounter any compatibility issues, please report them in the "Issues" section of this GitHub page.
The configuration file must be named LargePageInjectorMods.toml
. Sample configs are provided in the configs
folder. To use a sample config, rename it to LargePageInjectorMods.toml
. The config file must be in the same folder as Injector.exe
and the game/application that gets launched.
LargePageInjectorMods.toml
)# Path to the game/application executable to launch
LaunchPath = "stellaris.exe" # For Stellaris
# LaunchPath = "factorio.exe" # Uncomment for Factorio
# Modules (DLLs or EXEs) to patch with mimalloc
ModulesToPatch = [
"stellaris.exe", # The main executable
# Add other modules if needed
# "example.dll",
]
# Verbosity level (0-4)
Verbosity = 0 # 0 = Silent, 1 = Errors, 2 = Warnings, 3 = Info, 4 = Debug
# Redirect console output to Injector (true/false)
RedirectConsoleOutput = true # Set to true to enable
# Enable beep sound after injection (true/false)
EnableBeep = true # Set to false to disable
# Environment variables to set
[Environment]
#Amount of RAM in GB allocated to Large Pages set to 0 to disable huge pages
MIMALLOC_RESERVE_HUGE_OS_PAGES = "8"
#Various Mimalloc Env vars which may boost performance
MIMALLOC_ARENA_EAGER_COMMIT = "1"
MIMALLOC_PURGE_DELAY = "10000"
MIMALLOC_RESET_DELAY = "10000"
Contributions to the LargePageInjectorMods are welcome! If you have suggestions for improvements or bug fixes, feel free to fork this repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
mimalloc
allocator.This mod is not officially endorsed by the creators of Stellaris. Use at your own risk.