Skip to content
Snippets Groups Projects

msdkenc: fix leaks on windows

All threads resolved!

commit ce2a94f5:

msdk: Use gst_clear_object()
`gst_object_replace()` is not supposed to be used for unreffing and
NULLing objects.

commit 2c4c9828:

msdk: Fix warning about unused variable on Windows

commit 4384dbd8:

msdk: Reorganize context preparation code
Split it out into a separate function with early exits to make the
flow clearer, and document what the function is doing clearly.
No functional changes.

commit b64693fe:

msdk: Fix increasing memory usage in dynamic pipelines
Our context is non-persistent, and we propagate it throughout the
pipeline. This means that if we try to reuse any gstmsdk element by
removing it from the pipeline and then re-adding it, we'll clone the
mfxSession and create a new gstmsdk context as a child of the old one
inside `gst_msdk_context_new_with_parent()`.

Normally this only allocates a few KB inside the driver, but on
Windows it seems to allocate tens of MBs which leads to linearly
increasing memory usage for each PLAYING->NULL->PLAYING state cycle
for the process. The contexts will only be freed when the pipeline
itself goes to `NULL`, which would defeat the purpose of dynamic
pipelines.

Essentially, we need to optimize the case in which the element is
removed from the pipeline and re-added and the same context is re-set
on it. To detect that case, we set the context on `old_context`, and
compare it to the new one when preparing the context. If they're the
same, we don't need to do anything.

Fixes #946 (closed)

Edited by Nirbheek Chauhan

Merge request reports

Pipeline #99228 passed

Pipeline passed for 1bcf44bb on nirbheek:fix-msdkenc-leak-windows

Merged by GStreamer Marge BotGStreamer Marge Bot 5 years ago (Jan 21, 2020 1:01am UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Haihao Xiang
  • Haihao Xiang
  • Nirbheek Chauhan added 2 commits

    added 2 commits

    • 337e502c - msdk: Reorganize context preparation code
    • 6ec15d5f - msdk: Fix increasing memory usage in dynamic pipelines

    Compare with previous version

  • Nirbheek Chauhan added 22 commits

    added 22 commits

    • 6ec15d5f...0c39068c - 18 commits from branch gstreamer:master
    • 6a847f73 - msdk: Use gst_clear_object()
    • fc200e08 - msdk: Fix warning about unused variable on Windows
    • bf36fbfc - msdk: Reorganize context preparation code
    • 04aa692c - msdk: Fix increasing memory usage in dynamic pipelines

    Compare with previous version

  • Nirbheek Chauhan resolved all threads

    resolved all threads

  • Nirbheek Chauhan changed the description

    changed the description

  • Haihao Xiang resolved all threads

    resolved all threads

  • Haihao Xiang added 7 commits

    added 7 commits

    • 04aa692c...bda68734 - 3 commits from branch gstreamer:master
    • c0d778c2 - msdk: Use gst_clear_object()
    • e83d5fd8 - msdk: Fix warning about unused variable on Windows
    • 6834a121 - msdk: Reorganize context preparation code
    • 1bcf44bb - msdk: Fix increasing memory usage in dynamic pipelines

    Compare with previous version

  • changed milestone to %1.17.1

  • Please register or sign in to reply
    Loading