Fix #109770: WM: Memory leak of timers for file browser report #109603
No reviewers
Labels
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, 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
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
Core
Module
Development Management
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
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109603
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "mod_moder:tmp_fix_mem_leak"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
After opening a new project through the file browser, memory leaks appear.
Note that I haven't looked deeply into this but
reports->reporttimer
is a pointer to awmTimer
that is owned by a wmWindowManager. So freeing an item like this could cause unrelated issues with thewm->timers
list.So if this leak is from the call to
BKE_reports_clear
inblock_create__close_file_dialog
you could remove that timer there like:My sense in the same as Harley's, can you confirm the timer isn't referenced elsewhere? - if so, note this in the code comments, else - remove any references to the timer before freeing.
Can you give steps to redo the bug, tested with
5c4510d39ecf84d71d6afd15329dafda4fcc8556
and I can't redo this leak.The ownership of
reports->reporttimer
needs to be clarified.Looking a bit deeper I think I would also need a way to reproduce the error.
This PR is only freeing a timer and those are all owned by a wmWindowManager (wm->timers). My guess is that you are seeing a leak caused by the
WM_report_banner_show
inwm_block_file_close_save
. Timers are only in that list while they are active and they generally don't live long. So my gut feeling is that you might have a situation where a banner is being shown whenwindow_manager_blend_read_data
is called.wm_close_and_free
later callswm_reports_free
But it looks like
wm_reports_free
makes the same mistake as I did earlier in this thread. It callsWM_event_remove_timer
on wm->reports.reporttimer but that function only marks the timer for deletion (adds a WM_TIMER_TAGGED_FOR_REMOVAL flag). It should also callwm_window_delete_removed_timers
to actually free it. Note thatWM_event_remove_timer
does however free timer-customdata if it exists, something missing from this PR.So I'd love a sample blend and instructions on how to recreate this leak. But it if it is hard to catch and reproduce you could consider adding
wm_window_delete_removed_timers
to the end ofwm_reports_free
and see if it fixes it.More complete playback steps:
How I see the leak stack:
WM_event_add_timer
->WM_report_banner_show
->wm_file_read_report
->wm_file_read_post
.Okay, that simplifies things then. I've updated the fix to be much more correct.
You are definitely missing steps to create this, as this does not include anything that would cause
WM_report_banner_show
to be called.Note that your list is in backwards order. You were probably looking at a stack list with the last item on top. so it was in wm_file_read_post that wm_file_read_report was called, which called WM_report_banner_show, which called WM_event_add_timer.
If you look at the source in wm_file_read_post where it calls wm_file_read_report only addons are loaded, which conflicts with your "Disable all addons" step. And you wouldn't get to WM_report_banner_show from there unless there is an error to show. Do you see an error message on the status bar?
If your PR as it is now fixes the problem, then try replacing your
with
The
wm_reports_free
line above these clears the reports, sets the wm->reports.reporttimer as deletable, but does not free it. wm_window_delete_removed_timers will then free it.,To me, commenting
wm_file_read_report
' call resolve leak.Rechecked. Addons don't seem to affect this.
Also, I will attach an archive with a folder and a file. Opening the file through the file browser results in a leak for me.
I'm not sure if this matters, so I listed the stack in order of leak up, not call order..
Could you please open a report with steps to redo this issue, I tried multiple times and couldn't redo it & having to figure out why in the review makes things more difficult to follow.
Fix: WM: Memory leak of timers for file browser reportto Fix #109770: WM: Memory leak of timers for file browser report@Harley @ideasman42 #109770
@ -606,6 +606,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
WM_drag_free_list(&wm->drags);
wm_reports_free(wm);
BLI_freelistN(&wm->timers);
Timers can themselves have allocated data, this should be replaced by a function which frees timer custom data (see:
WM_TIMER_NO_FREE_CUSTOM_DATA
).Suggest adding
WM_event_timer_free_data(...)
whichWM_event_remove_timer
can call too.Committed a fix
6be0c90eab
.Note that the memory leak is quite harmless as it was only a leak on exit and freeing the memory just suppresses the warnings.
There was however a bug where reports which didn't set the window were suppressed (resolved by
8a73c36643
).There is a more general issue that timers without windows aren't freed while Blender runs.
It's up to the owner to free them (which may be acceptable) but seems error prone as add-ons could for e.g. add timers without windows and never remove them. We might for e.g. want timers to be freed when a new file is loaded for e.g.
This is more an API design issue though.
Pull request closed