baconya-BaconMemory icon

BaconMemory

Less RAM, same game: about 1.7 GB less in a round of a 100+ mod pack. Long sounds stay compressed or stream, short ones load on first play, the game's own are freed until they play, and shaders stay mostly packed. Mod files untouched.

By baconya
Last updated 2 days ago
Total downloads 395
Total rating 1 
Categories AI Generated Performance BepInEx Client-side Mods
Dependency string baconya-BaconMemory-1.0.0
Dependants 2 other packages depend on this package

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2305 icon
BepInEx-BepInExPack

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

Preferred version: 5.4.2305

README

BaconMemory

BaconMemory

Less RAM, same game.
Long sounds stay compressed · Short ones load when they first play · Shaders unpack as needed · Mod files never changed

Lethal Company unpacks a sound into RAM when it loads or first plays, and keeps it there, at 10 to 20 times its compressed size. In a big modpack that adds up to gigabytes, most of it in long sounds: music, ambience, alarms, audio logs. BaconMemory keeps long sounds compressed and lets Unity unpack them bit by bit while they play, which is what Unity recommends for long sounds. Short sounds are still unpacked, so they cost no CPU while they play, but the ones in moons' and interiors' bundles now load the first time they play instead of all at once when the game starts, and the game's own are freed until they play. And mods' shaders keep most of their variants packed until the game needs them.

What it does

  • SoundAPI sound packs stream their long sounds. SoundAPI unpacks every sound of a pack when the game starts. Sounds of 10 seconds or more now stream from their files while they play. With LethalResonance that's 87 sounds: about 400 MB less RAM, and the pack loads in half the time. When one of them plays in several places at once, like the ship's four thrusters, each place gets a stream of its own.
  • Long sounds in mods' asset bundles stay compressed. Most mods ship their sounds set to be unpacked, Unity's default. BaconMemory makes a copy of each bundle that has long sounds, with only those sounds set to stay compressed, and loads the copy instead. In The Company Adventures that's 1,530 sounds in 111 bundles. Unpacked, they take up to 1.8 GB from the bundles loaded at the start, plus up to 300 MB for the moon you're on, and the game unpacks more of them the longer you play.
  • Short sounds in LethalLevelLoader's bundles load the first time they play. LethalLevelLoader loads the bundles of every moon and interior when the game starts, and with them the short sounds of every interior: in The Company Adventures, about 220 MB of them are unpacked by the time the main menu is up. In BaconMemory's copies those sounds load the first time they play instead, in the background, so the sounds of interiors you haven't been to stay out of RAM. Only .lethalbundle files get this: a sound loads from its bundle, and LethalLevelLoader keeps those loaded for the whole game.
  • The game's own sounds are freed until they play. The game loads its sounds with its scenes, unpacked: in The Company Adventures about 160 MB by the main menu and 330 MB in orbit. Its files must stay as they are, so they get no copies. Instead, each time a scene loads, BaconMemory frees the ones a SoundAPI pack always replaces, since they never play themselves, and the short ones. Unity loads a freed sound back from the game's files the first time it plays, which held the game for 0.5 to 4 ms per short sound in tests at the main menu. Long sounds that no pack replaces stay loaded, since loading one back takes longer: 51 ms for a 43 s one.
  • Mods' shaders keep most of their variants packed. Unity unpacks every variant of a shader when it loads, and mods' shaders carry thousands that a game never draws: a mod's copy of HDRP's main shader takes up to 130 MB unpacked. Before mods load, BaconMemory sets Unity's own limit on how many chunks of variants a shader keeps unpacked, to two, so the rest stay packed until the game needs one of them. The game's own shaders load before BaconMemory, so they stay as they are.

Long sounds that stay compressed cost a little CPU while they play, on Unity's audio thread, not the one that draws frames. A short sound starts a moment late the first time it plays, while it loads: 10 to 30 ms later than once loaded, in tests at the main menu. A shader variant the game hasn't drawn yet can take a moment longer when its chunk has to be unpacked first.

A small card at the bottom of the main menu, in the game's own orange, shows what BaconMemory is doing: while it makes copies, a progress bar and the time left; otherwise, for a few seconds, how much RAM it saves right now.

RAM saved

Measured on one PC in Task Manager, with a test that plays the same round by itself each time: Experimentation with a fixed map seed, then 150 s inside.

In The Company Adventures, a modpack of 100+ mods that already has LethalSponge, LethalPerformance, CullFactory and Faster Load AssetBundles, inside Wesley's Expanded facility:

Without BaconMemory With BaconMemory
Main menu 8,608 MB 7,065 MB
In orbit 9,060 MB 7,390 MB
On the moon 9,200 MB 7,490 MB

That's about 1.7 GB less in a round. Mods' and SoundAPI's sounds save about 900 MB of it, shaders about 630 MB and the game's own sounds about 190 MB. The game's own sounds show in Task Manager only once the ship and the moon load, since Unity keeps memory it frees for what it loads next. Inside the interior the frame rate was the same with and without BaconMemory: about 350 FPS, and no frame took over 33 ms.

In vanilla, with only BepInEx installed, inside the game's own Facility:

Without BaconMemory With BaconMemory
Main menu 1,139 MB 1,140 MB
In orbit 1,541 MB 1,467 MB
On the moon 1,961 MB 1,902 MB

Vanilla has no mods' sounds, sound packs or shaders for BaconMemory to work on, so it saves only about 60 to 75 MB there, once the ship loads. No frame took over 33 ms inside, with or without it.

How the copies work

  • Mod files are never changed. Copies go in BepInEx/cache/BaconMemory/SoundBundles. In The Company Adventures they take about 4.2 GB of disk space, and no other space is needed while they're made.
  • The copies are made in the background once the main menu is up, so your game starts as fast as before. In the menu they're made at full speed. In The Company Adventures that takes a minute or two. While you play, one thread carries on slowly, and it pauses during a round. Writes are capped either way, so the drive never gets flooded.
  • Moons load their bundle each time you land, so a moon uses its copy as soon as it's made. Everything else, such as interiors, loads when the game starts, so its copies are used after you restart the game. Starting a new run isn't enough.
  • Later starts only compare file sizes and dates. A mod that's added or updated gets its copies in the background the same way.
  • Each copy is checked against its bundle before it's used: the only bytes that differ are the sounds' settings.
  • Should a mod unload a .lethalbundle but keep what it loaded from it, its short sounds couldn't load anymore. BaconMemory notices, and from the next start that bundle loads as it is until its copy is made again with its short sounds loaded up front.
  • When a mod is removed, its copies are deleted.
  • Bundles that a mod loads with a CRC check stay as they are, since a changed copy wouldn't pass it. In The Company Adventures that's GeneralImprovements'.

Settings

All in BepInEx/config/baconmemory.cfg, and in LethalConfig if you have it. They take effect the next time the game starts.

Setting Default What it does
Stream long SoundAPI sounds on Streams the long sounds of SoundAPI sound packs.
Keep long mod sounds compressed on Keeps long sounds in mods' bundles compressed.
Load short mod sounds when they first play on Lets short sounds in .lethalbundle files load the first time they play. With this and the one above off, the copies are deleted.
Free vanilla sounds until they play on After each scene loads, frees the game's own sounds that a SoundAPI pack always replaces, and its short ones. They load back when they play.
Shortest long sound (seconds) 10 Where long sounds start, for all of the above. Changing it makes the copies again.
Bundles to leave alone empty Bundle file names, separated by commas, whose sounds stay as they are.
Unpack shaders as needed on Keeps at most two chunks of a mod shader's variants unpacked at once.
Show the main menu card on Shows the card in the main menu.

Works with

BaconMemory needs only BepInEx. These mods aren't needed, but it works with them:

  • Faster Load AssetBundles makes faster-loading copies of bundles too. BaconMemory's copies load fast the same way, so for the bundles it copies, that mod's copies go unused, and that mod deletes them after 7 days.
  • LethalSponge, LethalPerformance and CullFactory work on graphics, meshes, textures and frame rate, and BaconMemory leaves all of that to them. It doesn't touch the game's graphics settings.
  • SoundAPI sound packs other than LethalResonance stream the same way.

Limits

  • The full saving on mods' sounds starts from the second start, once the copies are made.
  • A mod that reads a long sound's samples gets nothing back from a compressed one. No mod in The Company Adventures does. If one of yours does, put its bundle's file name in Bundles to leave alone.

The Bacon mods

Get the ones you want. The Company Adventures has BaconFixer, BaconTerminal and BaconGameRules set up to work together.

Mod What it does
BaconFixer BaconFixer Fixes only, for any modpack.
BaconMemory BaconMemory
You're here
Less RAM, same game: about 1.7 GB less in a round of a big modpack.
BaconTerminal BaconTerminal Weather bonuses, loot estimates, interior odds and day length in the terminal, Modern tables for the moons and the store, and terminal themes and styles.
BaconGameRules BaconGameRules Easy, Normal, Hard, Brutal or your own rules for each save file, and map seeds to replay.
The Company Adventures The Company Adventures A modpack with BaconFixer, BaconTerminal, BaconGameRules and 100+ more mods: 53 new moons, 13 new interiors, new weathers and more.

Feedback

Found a bug, or a sound that plays wrong? Message me on Discord: bac_kun.

AI disclosure

The code and this README were generated with Claude Code, Anthropic's AI coding agent. The author directed the work and tested the mod in game.