Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak when converting GST sample tags #1929

Merged
merged 1 commit into from Aug 24, 2020

Conversation

kingosticks
Copy link
Member

@kingosticks kingosticks commented Aug 23, 2020

Embedded cover art, and other tags exposed to us as type Gst.Sample, were
causing memory leaks when converted to plain Python types using
GstBuffer.extract_dup(). extract_dup() expects the caller to free the
memory it allocates but older versions of the python3-gi don't seem to do
this. The workaround is to access samples using GstMemory methods instead.

This issue was present on Buster 10 systems (python-gi 3.30.4) but not on
Ubuntu 20.04 (python-gi 3.36.0).

Fixes #1827
Zulip Topic

@kingosticks kingosticks added the A-audio Area: Audio layer label Aug 23, 2020
@kingosticks kingosticks added this to the v3.0.3 milestone Aug 23, 2020
@codecov
Copy link

codecov bot commented Aug 23, 2020

Codecov Report

Merging #1929 into develop will decrease coverage by 0.14%.
The diff coverage is 9.09%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1929      +/-   ##
===========================================
- Coverage    76.78%   76.64%   -0.15%     
===========================================
  Files           55       55              
  Lines         4691     4701      +10     
===========================================
+ Hits          3602     3603       +1     
- Misses        1089     1098       +9     
Impacted Files Coverage Δ
mopidy/audio/tags.py 79.56% <9.09%> (-8.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 889c8a8...55dec06. Read the comment docs.

@kingosticks kingosticks self-assigned this Aug 23, 2020
mopidy/audio/tags.py Outdated Show resolved Hide resolved
…dy#1827)

Embedded cover art, and other tags exposed to us as type Gst.Sample, were
causing memory leaks when converted to plain Python types using
GstBuffer.extract_dup(). extract_dup() expects the caller to free the
memory it allocates but older versions of Python 3 PyGObject don't seem
to do this. The workaround is to access buffer data using GstMemory
methods instead.

This issue was found to be present on Buster 10 systems
(python-gi 3.30.4) but not on Ubuntu 20.04 (python-gi 3.36.0).

Mopidy memory usage after scanning 2861 tracks:
Without fix: 163.2MB
With fix: 54.1MB
@jodal jodal merged commit 30b2348 into mopidy:develop Aug 24, 2020
0 of 2 checks passed
@kingosticks kingosticks deleted the fix/scanner-tags-memory-leak branch September 10, 2020 14:34
@kingosticks
Copy link
Member Author

I just stumbled upon #1472 which was related to this.

@LeoCal
Copy link

LeoCal commented Nov 6, 2020

Hello, thanks for fixing this issue. When do you plan on merging back to the master branch?

@jodal jodal modified the milestones: v3.0.3, v3.1.0 Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-audio Area: Audio layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apparent memory leak during normal MP3 playback
4 participants