Fix #117108: Memory leak report with static select engine data #117147

Merged
Hans Goudey merged 1 commits from HooglyBoogly/blender:fix-select-engine-global-leak into main 2024-01-16 01:55:27 +01:00
Member

Now that the select engine data uses non-trivial objects in its global
data, storing it at the global scope causes trouble due to arbitrary
construction and destruction order. Instead use the construct on first use
idiom to make the order clear. Though this struct probably shouldn't be
static at all, it does simplify memory management as well, it's nice to
remove the need to manually clear the arrays.

Now that the select engine data uses non-trivial objects in its global data, storing it at the global scope causes trouble due to arbitrary construction and destruction order. Instead use the construct on first use idiom to make the order clear. Though this struct probably shouldn't be static at all, it does simplify memory management as well, it's nice to remove the need to manually clear the arrays.
Hans Goudey added 1 commit 2024-01-15 21:53:19 +01:00
Now that the select engine data uses non-trivial objects in its global
data, storing the data at the global scope causes more trouble than it's
worth. Instead use the construct on first use idiom to make it clear
when the data is first constructed or destructed. Though this struct
probably shouldn't be static at all, it does simplify memory management
as well, removing the need to manually clear the arrays causing the issue.
Germano Cavalcante approved these changes 2024-01-15 22:41:17 +01:00
Germano Cavalcante left a comment
Member

It's a little strange, but it seems to work well. Even with --debug and WITH_CXX_GUARDEDALLOC Blender's leak detector does not detect the memory of these arrays.

A little unsure if this is just hiding the problem. But it seems to be an efficient solution.

Maybe there could be a comment explaining why this is so.

It's a little strange, but it seems to work well. Even with `--debug` and `WITH_CXX_GUARDEDALLOC` Blender's leak detector does not detect the memory of these arrays. A little unsure if this is just hiding the problem. But it seems to be an efficient solution. Maybe there could be a comment explaining why this is so.
Author
Member

Maybe there could be a comment explaining why this is so.

Not sure, it would just be a description of how static variables work, and this pattern is used commonly across Blender code for this reason.

>Maybe there could be a comment explaining why this is so. Not sure, it would just be a description of how static variables work, and this pattern is used commonly across Blender code for this reason.
Hans Goudey merged commit 17040a0b24 into main 2024-01-16 01:55:27 +01:00
Hans Goudey deleted branch fix-select-engine-global-leak 2024-01-16 01:55:29 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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 & 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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#117147
No description provided.