Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trimesh leaks memory unless full cyclic collector used #71

Closed
jonathanhogg opened this issue Jan 31, 2025 · 0 comments · Fixed by #72
Closed

trimesh leaks memory unless full cyclic collector used #71

jonathanhogg opened this issue Jan 31, 2025 · 0 comments · Fixed by #72
Assignees
Labels
🐞 bug Something isn't working 🎨 render Anything to do with rendering (windows, physics, etc.)

Comments

@jonathanhogg
Copy link
Owner

Unfortunately, trimesh objects seem to involve a bunch of cycles without any convenient way to break them. So the objects leak unless a full collection is done. However, doing a full collection involves about a 100ms delay (on my fast laptop) so it causes visible jank.

There are a few places where I use trimesh operations: things like loading external meshes and doing snap_edges. However, mostly I'm just using them as convenient stores of the vertex and face data. Given that, perhaps the smart thing to do is to store that data outside of a trimesh object.

I only need per-vertex coord, normal and UV, and per-face vertex numbers. I could just store these in two numpy arrays that are arranged so as to be directly convertible into the buffers we need for the shader. The main thing I'm lacking is vertex normal calculation, but I've already designed Cython code for doing this in the Kinect plug-in.

@jonathanhogg jonathanhogg self-assigned this Jan 31, 2025
@jonathanhogg jonathanhogg added 🐞 bug Something isn't working 🎨 render Anything to do with rendering (windows, physics, etc.) labels Jan 31, 2025
jonathanhogg added a commit that referenced this issue Feb 2, 2025
Adds new `get_arrays()` and `build_arrays()` and fills these in the 
obvious operations and primitives. Also only do a full collection if a 
trimesh object is released and separate updating cache timestamps from 
cache clearing. Fixes #71 - or, at least, improves it. In a further 
positive, the new normals calculation function is faster than the 
trimesh one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🎨 render Anything to do with rendering (windows, physics, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant