PoolOpt

版本 v0.9.3·更新於 2023-09-04

Optimize memory pools on loading gamesaves / 加載遊戲存檔時優化內存池的使用

模組介紹 作者原文

PoolOpt

Optimize memory pools on loading gamesaves

加載遊戲存檔時優化內存池的使用

Changelog

  • 0.9.3

+ Fix crash on calling SetEntityCapacity()

+ Reduce copies of Lists to improve performance

  • 0.9.2

+ Fix a issue that may delete used slots in trash pool

+ Fix compatibility issue with other mods (expecially DSPOptimizations) by calling SetXXXCapacity() on shrinking capacity of pools

  • 0.9.1

+ Fix a bug that may cause game crash on shrinking storage memory pools.

Notes

  • Does not optimize some rarely uses pools, mostly UI related.
  • Does not optimize solar sails' pool, please use button on dyson sphere panel from original game to clean it up.

Mechanism

  • The game uses a lot of memory pools in array to store data, sizes and capacities of these pools are increased on demand but never decreased, even most data inside are not used due to dismantle objects. Unused slot IDs are save in recycle array for reuse.
  • Some game functions loop through all allocated slots in the pool, so the size of the pool will affect the performance.
  • This mod will optimize the memory pools when loading gamesaves, strip the unused slots from tail and reduce the size of the pool and recycle array, for better performance.

TODO

  • Remove the unused slots from middle of the pool, which leads to ID change for stored objects, needs more investigation.

說明

  • 不會優化一些很少使用的內存池,主要是UI相關的。
  • 不會優化太陽帆的內存池,請使用原版遊戲中的戴森球面板上的按鈕進行清理。

原理

  • 遊戲使用了大量的內存池數組來存儲數據,這些內存池的大小和容量是隻會隨需求膨脹不會收縮的,即使由於拆除物體導致內部大多數數據不再使用。而未使用的槽位ID會被保存在回收數組中以供重複使用。
  • 一些遊戲功能會循環遍歷內存池中的所有分配過的槽位,因此內存池的大小會影響性能。
  • 本MOD會在加載遊戲存檔時優化內存池,去除尾部未使用的槽位,減少內存池數組和回收數組的大小,以獲得更好的性能。

TODO

  • 去除內存池中間的未使用槽位,這會導致物件的存儲ID發生變化,需要進一步調研。

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

xiaoye97-BepInEx

檔案與校驗

檔案名稱
PoolOpt-0.9.3.zip
檔案大小
17.3 KiB