Memory leak in material preview viewport shading when playing back an animation #106049

Open
opened 2023-03-23 15:57:43 +01:00 by Sebastian Parborg · 1 comment

System Information
Operating system: Gentoo Linux
Graphics card: AMD VEGA10

Blender Version
Broken: Latest git version

Short description of error
When playing back animations in the viewport there is a memory leak in the drawing code it seems.

Exact steps for others to reproduce the error

  1. Download and open the attached .blend file
  2. Switch the viewport to "material preview"
  3. Playback the animation
  4. Notice that the memory usage keeps growing.

If Blender is compiled with ASAN this is one of the reported memory leaks:

Indirect leak of 14880 byte(s) in 620 object(s) allocated from:
    #0 0x7f46b3864fff in __interceptor_malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/12/libasan.so.8+0xbcfff)
    #1 0x558abdd904c2 in MEM_lockfree_mallocN /home/zed/prog/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:247
    #2 0x558abdd8fc5b in MEM_lockfree_dupallocN /home/zed/prog/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:118
    #3 0x558aa605abbb in node_socket_copy /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:2266
    #4 0x558aa6041973 in ntree_copy_data /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:186
    #5 0x558aa5ceefb3 in BKE_id_copy_ex /home/zed/prog/blender/source/blender/blenkernel/intern/lib_id.c:640
    #6 0x558aa6068ce4 in ntreeLocalize /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:3263
    #7 0x558aa6068fec in ntreeLocalize /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:3270
    #8 0x558aa6068fec in ntreeLocalize /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:3270
    #9 0x558abcda0cd9 in GPU_material_from_nodetree /home/zed/prog/blender/source/blender/gpu/intern/gpu_material.c:839
    #10 0x558aa9cee579 in DRW_shader_from_material /home/zed/prog/blender/source/blender/draw/intern/draw_manager_shader.c:528
    #11 0x558aa9834341 in eevee_material_get_ex /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_shaders.cc:1376
    #12 0x558aa98346f4 in EEVEE_material_get /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_shaders.cc:1405
    #13 0x558aa97f96c9 in material_opaque /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_materials.c:613
    #14 0x558aa97fc6ce in eevee_material_cache_get /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_materials.c:778
    #15 0x558aa97fc6ce in EEVEE_materials_cache_populate /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_materials.c:827
    #16 0x558aa97a1886 in EEVEE_cache_populate /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_engine.c:116
    #17 0x558aa968db37 in drw_engines_cache_populate /home/zed/prog/blender/source/blender/draw/intern/draw_manager.c:1077
    #18 0x558aa969367b in DRW_draw_render_loop_ex /home/zed/prog/blender/source/blender/draw/intern/draw_manager.c:1733
    #19 0x558aa9692538 in DRW_draw_view /home/zed/prog/blender/source/blender/draw/intern/draw_manager.c:1636
    #20 0x558aaff5effa in view3d_draw_view /home/zed/prog/blender/source/blender/editors/space_view3d/view3d_draw.cc:1552
    #21 0x558aaff5f378 in view3d_main_region_draw /home/zed/prog/blender/source/blender/editors/space_view3d/view3d_draw.cc:1586
    #22 0x558aab2b3ec7 in ED_region_do_draw /home/zed/prog/blender/source/blender/editors/screen/area.cc:536
    #23 0x558aa8ad749d in wm_draw_window_offscreen /home/zed/prog/blender/source/blender/windowmanager/intern/wm_draw.c:960
    #24 0x558aa8ad8b78 in wm_draw_window /home/zed/prog/blender/source/blender/windowmanager/intern/wm_draw.c:1125
    #25 0x558aa8ada88d in wm_draw_update /home/zed/prog/blender/source/blender/windowmanager/intern/wm_draw.c:1385
    #26 0x558aa8ac1333 in WM_main /home/zed/prog/blender/source/blender/windowmanager/intern/wm.c:649
    #27 0x558aa57d6708 in main /home/zed/prog/blender/source/creator/creator.c:585
    #28 0x7f469e14a2c9  (/lib64/libc.so.6+0x232c9)

Note that there are some seemingly unrelated asserts from the the custom data layers.
@JacquesLucke and @HooglyBoogly can you guys look into the asserts?
They are probably unrelated to the memleak, but I don't think our production files should trigger asserts if everything is fine.

**System Information** Operating system: Gentoo Linux Graphics card: AMD VEGA10 **Blender Version** Broken: Latest git version **Short description of error** When playing back animations in the viewport there is a memory leak in the drawing code it seems. **Exact steps for others to reproduce the error** 1. Download and open the attached .blend file 2. Switch the viewport to "material preview" 3. Playback the animation 4. Notice that the memory usage keeps growing. If Blender is compiled with ASAN this is one of the reported memory leaks: ``` Indirect leak of 14880 byte(s) in 620 object(s) allocated from: #0 0x7f46b3864fff in __interceptor_malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/12/libasan.so.8+0xbcfff) #1 0x558abdd904c2 in MEM_lockfree_mallocN /home/zed/prog/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:247 #2 0x558abdd8fc5b in MEM_lockfree_dupallocN /home/zed/prog/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:118 #3 0x558aa605abbb in node_socket_copy /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:2266 #4 0x558aa6041973 in ntree_copy_data /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:186 #5 0x558aa5ceefb3 in BKE_id_copy_ex /home/zed/prog/blender/source/blender/blenkernel/intern/lib_id.c:640 #6 0x558aa6068ce4 in ntreeLocalize /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:3263 #7 0x558aa6068fec in ntreeLocalize /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:3270 #8 0x558aa6068fec in ntreeLocalize /home/zed/prog/blender/source/blender/blenkernel/intern/node.cc:3270 #9 0x558abcda0cd9 in GPU_material_from_nodetree /home/zed/prog/blender/source/blender/gpu/intern/gpu_material.c:839 #10 0x558aa9cee579 in DRW_shader_from_material /home/zed/prog/blender/source/blender/draw/intern/draw_manager_shader.c:528 #11 0x558aa9834341 in eevee_material_get_ex /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_shaders.cc:1376 #12 0x558aa98346f4 in EEVEE_material_get /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_shaders.cc:1405 #13 0x558aa97f96c9 in material_opaque /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_materials.c:613 #14 0x558aa97fc6ce in eevee_material_cache_get /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_materials.c:778 #15 0x558aa97fc6ce in EEVEE_materials_cache_populate /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_materials.c:827 #16 0x558aa97a1886 in EEVEE_cache_populate /home/zed/prog/blender/source/blender/draw/engines/eevee/eevee_engine.c:116 #17 0x558aa968db37 in drw_engines_cache_populate /home/zed/prog/blender/source/blender/draw/intern/draw_manager.c:1077 #18 0x558aa969367b in DRW_draw_render_loop_ex /home/zed/prog/blender/source/blender/draw/intern/draw_manager.c:1733 #19 0x558aa9692538 in DRW_draw_view /home/zed/prog/blender/source/blender/draw/intern/draw_manager.c:1636 #20 0x558aaff5effa in view3d_draw_view /home/zed/prog/blender/source/blender/editors/space_view3d/view3d_draw.cc:1552 #21 0x558aaff5f378 in view3d_main_region_draw /home/zed/prog/blender/source/blender/editors/space_view3d/view3d_draw.cc:1586 #22 0x558aab2b3ec7 in ED_region_do_draw /home/zed/prog/blender/source/blender/editors/screen/area.cc:536 #23 0x558aa8ad749d in wm_draw_window_offscreen /home/zed/prog/blender/source/blender/windowmanager/intern/wm_draw.c:960 #24 0x558aa8ad8b78 in wm_draw_window /home/zed/prog/blender/source/blender/windowmanager/intern/wm_draw.c:1125 #25 0x558aa8ada88d in wm_draw_update /home/zed/prog/blender/source/blender/windowmanager/intern/wm_draw.c:1385 #26 0x558aa8ac1333 in WM_main /home/zed/prog/blender/source/blender/windowmanager/intern/wm.c:649 #27 0x558aa57d6708 in main /home/zed/prog/blender/source/creator/creator.c:585 #28 0x7f469e14a2c9 (/lib64/libc.so.6+0x232c9) ``` Note that there are some seemingly unrelated asserts from the the custom data layers. @JacquesLucke and @HooglyBoogly can you guys look into the asserts? They are probably unrelated to the memleak, but I don't think our production files should trigger asserts if everything is fine.
Sebastian Parborg added the
Priority
Normal
Status
Needs Triage
Type
Report
labels 2023-03-23 15:57:43 +01:00
Jeroen Bakker was assigned by Sebastian Parborg 2023-03-23 15:59:04 +01:00
Member

The customdatalayer asserts are due to the status of UVMaps (active_index / active_render wrong). Could be worked around by

import bpy

for mesh in bpy.data.meshes:
    if len(mesh.uv_layers) > 0:
        mesh.uv_layers.active_index = 0
        mesh.uv_layers[0].active_render = True

See also #105860, eeb21fc8c3

The customdatalayer asserts are due to the status of UVMaps (`active_index` / `active_render` wrong). Could be worked around by ``` import bpy for mesh in bpy.data.meshes: if len(mesh.uv_layers) > 0: mesh.uv_layers.active_index = 0 mesh.uv_layers[0].active_render = True ``` See also #105860, eeb21fc8c316
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#106049
No description provided.