Please read the mod's description! This mod does not improve performance. It is only (maybe) useful if you encounter the problem described in the mod's description.
Memory Cleanup Mod for SPT Server 4.x.x
⚠️ This mod does not improve performance.
If you’re here hoping that this mod will increase your FPS, reduce lag, or enhance other performance-related aspects, you’re in the wrong place. Only install this mod if you’ve experienced the issue described below. Do not install it as a preventive measure.
I run SPT-Server 4.x on a small Linux-based VServer with just 4 GB of memory for my friends and me. I noticed that SPT-Server 4.x gradually consumes a large amount of memory over time and doesn’t release it, even when available memory is running low. This issue seems to stem primarily from .NET, and is therefore not a widespread SPT4 problem.
To address this, I created this mod, which forces the server to clean up memory at configurable time intervals (every 5 minutes by default). This may cause minor lag spikes each time the cleanup runs, but I prefer that over having our VServer run out of memory after a few hours.
Additionally, I’ve configured our SPT-Server 4.x to restart every 24 hours.
Once again, do not install this mod to improve performance — only use it if you encounter the same memory issue.
Extract the contents of the .zip or .7z file into your SPT(-Server) directory.
You should end up with the following files copied to your SPT(-Server) directory:
- C:\yourSPTfolder\SPT\user\mods\com.swiftxp.spt.servermemorycleaner\SwiftXP.SPT.ServerMemoryCleaner.Server.dll
- C:\yourSPTfolder\SPT\user\mods\com.swiftxp.spt.servermemorycleaner\config\config.json
You can configure the cleanup interval in the mod’s configuration file, located here:
- C:\yourSPTfolder\SPT\user\mods\com.swiftxp.spt.servermemorycleaner\config\config.json
For those interested in what the mod actually does:
SPT-Server 4.x is based on the .NET Framework, which is a managed runtime environment. The .NET runtime automatically handles tasks such as memory allocation and garbage collection.
Objects that are 85,000 bytes or larger are allocated on a special area of memory called the Large Object Heap (LOH). The LOH is only garbage-collected during a full (generation 2) collection, and by default it is not compacted (defragmented). This means that over time, the LOH can grow large and become fragmented, even after memory has been freed.
This mod periodically forces the .NET runtime to:
- Trigger a full garbage collection, which cleans up unused memory in the LOH, and
- Compact (defragment) the LOH to reduce its size.
The SPT team has already taken measures to optimize memory usage, and under normal circumstances, the .NET Garbage Collector works very reliably. Nevertheless, I have encountered the issue described above on our Linux-based VServer.
Again: If you do not experience this exact problem, please do not install this mod.
5.67 KB
38 Downloads
Released Yesterday at 9:20 PM
First release.
Details
-
GUID
com.swiftxp.spt.servermemorycleaner
-
Category
-
License
-
Source Code
-
Latest Version VirusTotal Results
-
Fika Compatible Version Available
Thank you very much for this - exactly what I need. I too had it on a 12 hourly reboot cycle to fix the “memory leak”.