Does Maya's Viewport 2.0 release GPU memory when nodes are deleted via script?
0 reputation · 09 Aug 2021, 18:23 UTC
0 reputation · 09 Aug 2021, 18:23 UTC
Autodesk Maya's Viewport 2.0 manages GPU resources through ViewportRenderUtil, which handles render targets for geometry and textures. When nodes are deleted programmatically, memory may not release as expected due to persistent references in internal caches.
The ViewportRenderUtil class appears to maintain references to deleted nodes, potentially causing GPU memory accumulation. Python script jobs listening to scene events can also prevent proper garbage collection of temporary objects.
Memory leaks in this subsystem may not appear in system monitors but degrade viewport performance over time. The behavior varies significantly between Maya versions 2018-2024, making consistent reproduction challenging.
Verification requires monitoring process memory while manipulating complex scenes and using Maya's MemoryUtil command to profile before and after operations. Testing with clean scenes helps isolate core behavior from scene-specific issues.
Key questions remain: Does ViewportRenderUtil automatically release GPU memory when nodes are deleted? How do script job references affect memory persistence? What is the recommended cleanup sequence for optimal memory management?
35775 reputation · 09 Aug 2021, 21:23 UTC
No — deleting nodes via script (cmds.delete()) removes them from the scene graph, but Viewport 2.0 does not immediately free the associated GPU buffers. The memory stays allocated until the viewport is explicitly refreshed or the view panel is redrawn.
cmds.delete(nodes)) purges the DAG nodes from the scene.cmds.refresh(suspend=False), modelEditor -e -refresh true, or by closing and reopening the model panel.ViewportRenderUtil maintains a resource cache for performance. When a node is deleted, the cache entries are not automatically invalidated; they persist until the next draw cycle or an explicit refresh forces a cache purge. This design avoids the overhead of per-deletion GPU deallocations during interactive editing.
Python script jobs that hold references to deleted nodes (or to temporary objects created during the deletion) can keep the internal caches alive longer, because the garbage collector cannot reclaim objects that are still referenced. The symptom is a gradual GPU memory climb during long‑running scripted sessions.
Observed across Maya 2018–2024. Some point releases purge caches more aggressively on delete, but the general pattern — release on refresh — holds throughout the range.
nvidia-smi or Maya’s memInfo command.cmds.delete(selected_nodes) via Python.cmds.refresh(suspend=False) (or toggle the model panel’s refresh).If you are running batch/headless Maya (no interactive viewport), the refresh path does not exist. In that mode, does the process eventually release GPU memory on its own, or does it require an explicit cmds.quit()? Confirming this determines whether a scheduled restart is needed for long batch runs.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.