• Hi Guest!

    We are extremely excited to announce the release of our first Beta1.1 and the first release of our Public AddonKit!
    To participate in the Beta, a subscription to the Entertainer or Creator Tier is required. For access to the Public AddonKit you must be a Creator tier member. Once subscribed, download instructions can be found here.

    Click here for information and guides regarding the VaM2 beta. Join our Discord server for more announcements and community discussion about VaM2.
  • Hi Guest!

    VaM2 Resource Categories have now been added to the Hub! For information on posting VaM2 resources and details about VaM2 related changes to our Community Forums, please see our official announcement here.
Anti-Stutter Patch

Plugins + Scripts Anti-Stutter Patch

Download [<1 MB]
  Contains executable files or external scripts. Ensure you trust the creator and apply your own security measures.
V3.0:
  • Use an offset-based approach instead of feature flags to retrieve GC_disable.
  • Limit the maximum heap size to 20 GB. VAM’s Unity/Mono “stability sweet spot” is around 12–16 GB; once the managed heap exceeds ~18–20 GB, Mono’s management overhead becomes extremely high and it’s prone to “Too many heap sections!” errors.
  • If you’re using CPU Performance Patch v13, the plugin will not work!!! Please use v12.



V2.0:Rewritten the switching logic, accurately determined the true state of the GC switch, and optimized the upper limit setting of Heap Size


Overview
Native GC Patcher is a high-performance Anti-Stutter & GC Manager for Virt-A-Mate (VaM). It interacts directly with the game's Mono runtime to control Garbage Collection (GC), eliminating micro-stutters caused by frequent GC spikes and preventing memory overflows during long sessions.

This plugin can only control the timing of GC operation and cannot clean up the memory usage of VAM.

Unlike standard script-based cleaners, this plugin runs natively via BepInEx, allowing it to "Lock" the GC when memory is safe (ensuring smooth framerates) and "Force Clean" intelligently when necessary.

Heap Size & RAM
FeatureHeap Size (Managed Heap)RAM (Physical Memory / Total Reserved)
DefinitionMemory reserved specifically for C# script objects by the Unity/Mono runtime.The total memory allocated by the VAM process from the OS.
RelationshipIt is a small subset of RAM.Includes the Heap, plus native assets like textures, meshes, and audio.
Content• List, Dictionary
• JSONStorable (VAM Params)
• Strings, Plugin variables
Heap Size (Included)
Textures (Largest consumer)
• Meshes (Geometry)
• Audio data
ManagerGarbage Collector (GC).
Automatically scans and clears unreferenced variables.
Unity Engine Core + OS.
Native assets are ignored by GC and must be unloaded manually.
PerformanceCauses Stutter / Lag.
When Heap is full or fragmented, GC pauses the game to clean up.
Causes Crash (CTD).
When RAM is exhausted, the OS kills the process.





Key Features
Zero-Stutter Mode (GC Locking)

The plugin locks the Mono Garbage Collector to prevent it from running randomly during gameplay, which is the main cause of periodic lag spikes in VaM.
GC is only allowed to run when memory usage hits your defined limit.

Smart Auto-Triggers

On Scene Load: Automatically performs a deep clean right after a scene finishes loading.
On Person Removed: Automatically cleans up memory when you delete a character, preventing "ghost" data from clogging your RAM.
Includes "Debounce" technology: If you delete multiple characters quickly, it waits until you are done before cleaning.

Smart RAM Detection

On first launch (or hardware change), the plugin detects your total System RAM and automatically sets a safe Memory Limit (defaulting to ~50% of your total RAM).


Requirements
Virt-A-Mate (v1.20 or newer recommended)
BepInEx 5.x (x64) installed in your VaM folder.


Installation
Ensure you have BepInEx installed. (If you see a BepInEx folder in your VaM root directory, you are good to go).
Copy the NativeGCPatcher.dll file into: .../Virt-A-Mate/BepInEx/plugins/
Start the game. You should see a status overlay in the top-left corner.

Controls & Usage
b3a9e63b559d22ca9f1e16669478ec0a.png

Ctrl + G: Toggle the Settings Window.
Ctrl + F: Toggle the GC Statu.

Enable Plugin :
Turns the entire logic on/off.

Memory Limit (GB) :
The Min value is set to 4GB, and the Max value is Capped at 50% of your Total RAM.
The threshold where GC is allowed to run. If usage is below this, GC is locked for smoothness.

GC On Scene Load : Triggers a cleanup immediately after a scene loads. Highly recommended.

GC On Person Removed : Triggers a cleanup when a Person atom is destroyed.

Show Overlay : Displays the mini status info in the top-left corner.


Configuration
You can edit settings via the in-game window (Ctrl+G) or by editing the config file at:
.../Virt-A-Mate/BepInEx/config/com.yours.gcpatcher.cfg



FAQ

Q: Why does delaying GC increase Heap Size?
A: Think of Unity's memory as a parking lot.

  1. Default Mode (Frequent GC):As soon as a car leaves (becomes garbage), GC immediately frees up that spot. New cars can park in these recycled spots.
    • Result: The parking lot stays small and efficient.
  2. Plugin Mode (Delayed GC):To prevent lag stutters, we lock the GC. This means even if data is garbage, it still "occupies" the spot. When new data arrives, it can't fit in the old spots, so the system is forced to expand the parking lot(allocate more RAM) to fit the new data.
    • Result: Even after a cleanup, the parking lot (Heap Size) remains permanently expanded.
The Trade-off:You are trading higher memory usage for a stutter-free experience.

Q: Why does the game freeze for a second sometimes?
A: That is the "Force GC" kicking in. It freezes the game briefly to reclaim memory. This is intentional and happens only when you hit your Memory Limit or trigger an event (like loading a scene), preventing random stutters during gameplay.

Q: My Memory Limit changed automatically?
A: The plugin detected a change in your system hardware (e.g., you upgraded RAM or moved to a new PC) and auto-adjusted the limit to a safe value.
  Contains executable files or external scripts. Ensure you trust the creator and apply your own security measures.
React to this content...

Share this resource

More resources from Ashu27

Latest updates

  1. New Version

    Use an offset-based approach instead of feature flags to retrieve GC_disable. Limit the maximum...
  2. New Version

    Optimized the code logic.

Latest reviews

Positive
Version: 2.0
The improvement offered by this script is astonishing. Complex plugin-heavy scenes that would tipically be plagued by constant lag spikes now run smoothly for several minutes at a time, even in VR. This is a problem I didn't think would ever be fixed in VAM 1, as it was thought to be unfixable. Truly amazing work.
Upvote 0
Back
Top Bottom