Slayerrr45-BundleSlimmer icon

BundleSlimmer

Cuts RAM use from big moon/interior mods. Converts LZMA asset bundles to disk-streamed LZ4 and fixes audio that sits decompressed in memory. Runs once per mod version.

Last updated a week ago
Total downloads 248
Total rating 0 
Categories AI Generated Performance
Dependency string Slayerrr45-BundleSlimmer-1.1.0
Dependants 1 other package depends on this package

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2100 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2100

README

BundleSlimmer

Big content mods (Wesley's Moons, Generic Moons, interior packs) ship their asset bundles LZMA-compressed. Unity can't read LZMA in pieces, so it unpacks the whole bundle into RAM and keeps it there for as long as the bundle is loaded. LethalLevelLoader keeps most bundles loaded all game. In a large pack that's several GB of private memory, and on 16 GB PCs it can crash the game with Could not allocate memory: System out of memory!.

BundleSlimmer fixes this before the game starts:

  • LZMA → chunked LZ4. Every LZMA asset bundle in BepInEx/plugins is rewritten as chunked LZ4, which Unity reads from disk 128 KB at a time instead of unpacking it into RAM.
  • Audio fix. Audio clips set to Decompress On Load are switched to Compressed In Memory, so they stop sitting in RAM as raw PCM. PCM clips are left alone.
  • Runs once. Finished bundles are remembered by size and date. Later launches skip them in a few milliseconds. When a mod updates, only its new files are converted.

Nothing inside a bundle changes apart from that one audio setting. Each rewritten file is unpacked again and checked byte for byte against the original data before it replaces the old one. If anything fails, the original file is left as it was.

First launch

The first launch with BundleSlimmer takes a few extra minutes. The BepInEx console shows BundleSlimmer lines while it works. For reference, about 200 bundles (4 GB) took 6.5 minutes on a Ryzen 7 5700G. It isn't frozen.

You need free disk space on the game's drive. LZ4 files are bigger than LZMA ones (about 1.4×), and each bundle is unpacked to a temporary file while it's converted. A bundle is skipped if converting it would leave less than KeepFreeGB free.

Config

BepInEx/config/lcmemfix.BundleSlimmer.cfg

Setting Default
Enabled true Turn the whole thing off.
FixAudio true Also apply the audio fix.
Threads 0 Bundles converted at once. 0 = half your CPU cores.
KeepFreeGB 3 Don't convert a bundle if it would leave less free space than this.

Good to know

  • It edits other mods' files on disk. Mod managers (r2modman, Gale) hard-link profile files to their download cache. BundleSlimmer deletes the profile's link before writing the new file, so the manager's cached copy stays original. Reinstalling a mod restores its original files, and BundleSlimmer converts them again on the next launch.
  • Uninstalling: remove the mod, then reinstall the converted mods if you want their original files back. The converted files work fine without BundleSlimmer.
  • Client-side. It doesn't touch networking. Players with and without it can play together.
  • Works alongside BepInEx Faster Load AssetBundles (its cache rebuilds once for the converted files) and LethalSponge.
  • Log: BepInEx/LogOutput.log. Search for BundleSlimmer. Any file it couldn't convert is listed with the reason.

Credits

  • LZMA decoder from the public-domain LZMA SDK by Igor Pavlov.
  • Built with Claude Code (Anthropic's Claude Opus 5.5).

MIT licensed. See LICENSE.