Bug 465626 - Memory Leak with calls to Application.documents() in Python
Summary: Memory Leak with calls to Application.documents() in Python
Status: REPORTED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Appimage Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-12 15:20 UTC by tom-jk
Modified: 2023-02-12 16:18 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tom-jk 2023-02-12 15:20:47 UTC
SUMMARY
Krita memory usage increases with each call to Application.documents(), or Krita.instance().documents(), or ki.documents() where ki = Krita.instance().


STEPS TO REPRODUCE
1. Have some images open in Krita.
2. Open Scripter.
3. Paste and Run the following:

ki = Krita.instance()
for i in range(0, 50000):
    ki.documents()

OBSERVED RESULT
Approximate change in krita memory usage as shown by system monitor:

images open - total change - change per call (total change/50000)
0 images - 0mb - 0mb
1 image - 22mb - 0.45kb
8 images - 150-200mb - 3.1-4.1kb
16 images - 335mb - 6.86kb

EXPECTED RESULT
no change in memory usage.

SOFTWARE/OS VERSIONS
Linux Mint 20 Cinnamon
Qt Version: 5.15.7
Krita Nightly Build #1910 (11-Feb-2023 16:09:00) 3cf61b0430093e9d3413f8a4325f78bf089df144

ADDITIONAL INFORMATION
- Assigning ki.documents() to variable, setting variable to None, doing del on variable - make no difference.
Comment 1 tom-jk 2023-02-12 16:18:54 UTC
Looking at just the Krita class (https://api.kde.org/krita/html/classKrita.html):
documents(), views() and windows() all leak.
extensions(), dockers() and actions() do not leak.
The leaky ones are putting new things in a list, while the ones that don't are just doing "return a->b".