Skip to content

Commit f2433a7

Browse files
committed
Fix trimesh memory leaking
It looks like the trimesh objects have reference loops in them and so are not being cleared by the per-frame `gc.collect(0)`. Run a full collection if we have thrown any model objects.
1 parent 2e94e2a commit f2433a7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/flitter/engine/control.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ async def run(self):
326326
logger.trace("State dictionary size: {} keys", len(self.state))
327327
if run_program is not None and run_program.stack is not None:
328328
logger.trace("VM stack size: {:d}", run_program.stack.size)
329-
Model.flush_caches()
329+
if Model.flush_caches():
330+
count = gc.collect(2)
331+
if count:
332+
logger.trace("Collected {} objects (full collection)", count)
330333
else:
331334
gc.collect(0)
332335

0 commit comments

Comments
 (0)