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

the memory leak is still exists even the latest version 8.0.3 because the InputContainer.close() is not work #838

Closed
4 tasks
hatcherfang opened this issue Dec 17, 2021 · 4 comments
Labels

Comments

@hatcherfang
Copy link

hatcherfang commented Dec 17, 2021

Overview

the memory leak is still exists even the latest version 8.0.3

Expected behavior

I expect fix the memory leak bug

Actual behavior

the memory leak where get the first frame and save it as picture

Traceback:

Line #    Mem usage    Increment  Occurrences   Line Contents
=============================================================
     6  56.8711 MiB  56.8711 MiB           1   @profile(precision=4)
     7                                         def test():
     8  56.9922 MiB   0.1211 MiB           1       path = "test.mp4"
     9  64.8047 MiB   7.8125 MiB           1       container = av.open(path)
    10                                             # help(container)
    11                                             # total_frames = container.streams.video[0]
    12                                             # help(total_frames)
    13                                             #path_to_video是你视频的路径
    14  64.8047 MiB   0.0000 MiB           1       first_video = container.decode(video=0)
    15  67.1406 MiB   2.3359 MiB           1       frame = next(first_video)
    16  78.2227 MiB  11.0820 MiB           1       frame_image = frame.to_image()
    17  78.8672 MiB   0.6445 MiB           1       frame_image.save('frame-0.jpg')
    18  78.9258 MiB   0.0586 MiB           1       container.close()
    19  71.2969 MiB  -7.6289 MiB           1       frame_image.close()
    20  71.2969 MiB   0.0000 MiB           1       first_video.close()
    21  71.2969 MiB   0.0000 MiB           1       del frame
    22  71.2969 MiB   0.0000 MiB           1       del frame_image
    23  71.3672 MiB   0.0703 MiB           1       help(container)
    24  71.3672 MiB   0.0000 MiB           1       del container
    25  71.3672 MiB   0.0000 MiB           1       print(gc.collect())

Investigation

You can see that the memory is 56.8711MiB at first, but the memory increase to 71.3672 MiB at the end.

Reproduction

{{ Steps to reproduce the behavior. If the problem is media specific, include a link to it. Only send media that you have the rights to. }}

Versions

root@75b5546dee3d:/app# python -m av --version
PyAV v8.0.3
git origin: [email protected]:PyAV-Org/PyAV
git commit: v8.0.3
library configuration: --disable-doc --disable-static --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-shared --enable-version3 --enable-zlib --prefix=/tmp/vendor
library license: GPL version 3 or later
libavcodec     58. 91.100
libavdevice    58. 10.100
libavfilter     7. 85.100
libavformat    58. 45.100
libavutil      56. 51.100
libswresample   3.  7.100
libswscale      5.  7.100
  • PyAV build:
pip install av==8.0.3
  • FFmpeg:
root@75b5546dee3d:/app/ruban/conference/preview# ffmpeg -version
ffmpeg version 4.1.6-1~deb10u1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 22.100 / 56. 22.100
libavcodec     58. 35.100 / 58. 35.100
libavformat    58. 20.100 / 58. 20.100
libavdevice    58.  5.100 / 58.  5.100
libavfilter     7. 40.101 /  7. 40.101
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  3.100 /  5.  3.100
libswresample   3.  3.100 /  3.  3.100
libpostproc    55.  3.100 / 55.  3.100

Research

I have done the following:

@jlaine
Copy link
Member

jlaine commented Dec 29, 2021

PR?

@jlaine
Copy link
Member

jlaine commented Dec 30, 2021

I don't understand how your output proves there is a memory leak, could you elaborate?

If memory serves, Python does not necessarily release memory back to the OS until the process exits.

@jlaine
Copy link
Member

jlaine commented Jan 25, 2022

Hello?

@jlaine
Copy link
Member

jlaine commented Mar 7, 2022

Closing, not enough to go on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants