You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using the library, some internal data structures can become obsolete and should be cleaned up to free memory. For example, empty chunks that no longer contain entities can be removed. Component storages can also have unused capacity that can be shrunk to save memory. The library provides a function to control this garbage collection process.
1353
+
1354
+
```lua
1355
+
---@paramno_shrink?boolean
1356
+
functionevolved.collect_garbage(no_shrink) end
1357
+
```
1358
+
1359
+
By default, [`evolved.collect_garbage`](#evolvedcollect_garbage) cleans up obsolete data structures and shrinks component storages to fit their current size. If you pass `true`, it only cleans up obsolete data structures and skips shrinking. This avoids the overhead of resizing storages, which can be expensive.
1360
+
1361
+
Call this function periodically to keep memory usage under control. It is best to call it between levels or during loading screens when performance is not critical. Also, call Lua's built-in garbage collector afterward to ensure all unused memory is freed.
1362
+
1363
+
```lua
1364
+
evolved.collect_garbage()
1365
+
collectgarbage('collect')
1366
+
```
1367
+
1349
1368
## Cheat Sheet
1350
1369
1351
1370
### Aliases
@@ -1481,7 +1500,7 @@ process :: system... -> ()
1481
1500
process_with :: system, ... -> ()
1482
1501
1483
1502
debug_mode :: boolean -> ()
1484
-
collect_garbage :: ()
1503
+
collect_garbage :: boolean? -> ()
1485
1504
```
1486
1505
1487
1506
### Classes
@@ -2007,7 +2026,8 @@ function evolved.debug_mode(yesno) end
0 commit comments