-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Memory overhead in scenes with many objects #1527
Comments
Results from memory profiling in Chrome devtools:
I'm surprised that instances of common classes like Accessor and GraphEdge were not more significant memory consumers. |
Ideas possibly worth exploring to reduce memory usage:
|
I think we can safely remove events associated with GraphEdge, i.e. the references between properties. See: The change improves the 'dispose' benchmark by 50%...
... the benchmark runs an arbitrary number of dispose() operations on an arbitrarily-large Document, so the number itself is not meaningful, but lower is better. The change also significantly reduces memory overhead while loading the |
Somewhat relevant: |
tl;dr — Scenes with many (1M+) meshes/nodes/accessors cause higher than expected memory cost and potential OOM
While investigating a recent question on the Blender Stack Exchange, I noticed that a glTF file linked from the question1 caused an OOM when running
gltf-transform inspect
. The file contained 200 MB of uncompressed binary data, which isn't a problem, but more importantly some 500,000 distinct mesh primitives. If the Node.js memory limit is around 4GB, that implies a memory cost of something like 8kb per mesh primitive. I haven't measured the memory allocation causes in Node.js yet, but the number looked higher than expected.I ran further tests by printing heap size incrementally during loading. Heap size went from nominal to 3.7GB after initializing accessors, and hit OOM while processing mesh primitives. Note, this is not the binary vertex data, which has very predictable binary size, but the property graph organizing the scene/nodes/meshes/accessors on top of that data. On a hunch, I next tried to disable all event dispatchers and event listeners (managed by property-graph). This reduced heap size after initializing accessors to 2.4GB, and the scene loaded. Without events, some graph edges are never connected to the Root, so this leaves us with two plausible causes:
My feeling is that (1) is easier to fix, but (2) is more likely, and some more investigation will be needed to determine if one of these, or something else, is the cause.
Footnotes
cad_machine.gltf, 7M vertices, 0.5M mesh primitives, 1.3M accessors ↩
The text was updated successfully, but these errors were encountered: