Lethal Company
Install with App

Details

Latest version
1.0.1
Last Updated
First Uploaded
Downloads
34
Likes
0
Size
87KB
Dependants

LethalWringer

LethalSponge, but on steroids.

To be fair to Sponge: this doesn't do everything Sponge does. It takes the one thing that kept your RAM in check - the UnloadUnusedAssets sweep Sponge runs once per in-game day - and runs it more often and at smarter moments, so memory stops creeping upward over a session instead of only getting wrung out at day rollover.

Inspired by LethalSponge. Fully standalone and clientside - it does not require Sponge, and works with or without it.

What it does

It calls Unity's Resources.UnloadUnusedAssets() - the same engine call Sponge uses - to reclaim memory from assets nothing references anymore (a moon you left, a dungeon that unloaded, dead enemies). Unity doesn't reclaim that memory on its own until something asks, so LethalWringer asks at the two moments it matters most:

  1. The moment you return to orbit after leaving a moon. The whole moon just became unreferenced, so this is the single biggest chunk of memory to reclaim - and a frame hitch up in orbit, with nobody in danger, costs you nothing. This is the important one.
  2. On a timer while you're on a moon. A safety net for long single-moon runs where RAM climbs without you ever going back to orbit.

The tradeoff

UnloadUnusedAssets causes a brief frame hitch each time it runs (that's why Sponge only does it on day rollover). The orbit sweep is effectively free because you're safe on the ship. The periodic on-moon one can hitch mid-gameplay, so its interval is a knob: more frequent means tighter RAM but more hitches.

Config

  • Enabled - master switch.
  • SweepOnReturnToOrbit - run one cleanup each time you get back to orbit from a moon. The big, cheap one. Default on.
  • IntervalMinutes - how often the periodic on-moon cleanup runs (default 10, range 2-60).
  • PeriodicAlsoRunsInOrbit - let the periodic timer also tick in orbit. Usually unnecessary with the orbit sweep on. Default off.
  • AlsoCollectGarbage - also force a managed GC after unloading. A little more RAM freed, a bigger hitch. Default off.
  • LogEachRun - print a line each cleanup showing the heap before/after.

Credits

Made by Pierre (Discord: samedude67). Inspired by LethalSponge by Scoops. Uses only Unity's built-in memory API, so it does not require Sponge.

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.