AI-Generated Three.js Dashboards Die in Minutes: Memory Leaks and Scene-Graph Growth Behind 'Crashed After 3 Days'
Without AI-aware cleanup, a Three.js dashboard can hit V8's 4GB heap cap in under an hour and degrade to regular jank within minutes. The reproduced curves give frontend teams a concrete checklist to audit any AI-generated or long-lived Three.js scene for the same three leaks.
AI-generated Three.js dashboards leak memory at a steady 1.38MB/s when the code rebuilds BufferGeometry, materials, and Meshes every frame without ever calling remove. A Node reproduction that simulates 60fps for 60 seconds shows 75.6MB of unreclaimable memory in 55 seconds, matching the theoretical 24KB per object times 60 frames. The leaked Float32Arrays hang on BufferAttribute, Mesh, and scene.children, so GC cannot touch them while the scene stays alive.
A second problem runs on the CPU side: scene.children keeps growing because nothing removes nodes, and three.js traverses the whole scene graph every render call. Measuring scales shows traversal time climbing from 0.058ms at 1000 children to 3.084ms at 16000, with a superlinear jump at the top. Combined with frustum culling, sorting, and draw call submission, the cost lands on the 16.7ms frame budget and produces the jank users see long before a crash.
A dispose() test in Node shows why the call alone is often useless: in three.js dispose() only broadcasts an event; actual GPU resource release happens inside WebGLRenderer's listener, and only for objects that were actually rendered. remove() alone lets the JS heap reclaim an object but leaves GPU resources allocated. The fixes are simple and verified on 0.187: reuse geometry with attribute.needsUpdate, remove then dispose in pairs inside a release function, use InstancedMesh for thousands of similar objects, and diagnose by checking scene.children.length and performance.memory before looking at GPU memory.
AI code generators optimize for a runnable demo, not a long-lived deployment, so they inherit tutorial habits that never dispose because demo pages are torn down wholesale.
The heapUsed measurement pitfall suggests many quick checks of AI-generated code may underestimate leaks by ignoring TypedArray storage, leading to false confidence.
All three pitfalls are basic API usage, not obscure knowledge; the failure is not missing expertise but missing operational context in training data.
The diagnosis order (JS heap before GPU) points out that most 'mysterious' lag in three.js dashboards is CPU-side scene graph growth, not a GPU bottleneck.