[Q] WASAPI exclusive mode memory leak - driver issue ?

Discussion in 'Videocards - NVIDIA GeForce Drivers Section' started by janos666, Sep 28, 2018.

  1. janos666

    janos666 Ancient Guru

    Messages:
    1,653
    Likes Received:
    407
    GPU:
    MSI RTX3080 10Gb
    I experienced some strange issues similar to a memory leak but couldn't really figure it out and it took a lot of involuntary experimentation (trying to use my PC normally but ending in troubleshooting) to get a little closer to the root of this problem.

    Main symptom:
    The system wide commit size (the "Commited" memory statistics in Task Manager) grows continuously (roughly at the speed of a gigabyte per every few minutes) until it reaches it's limit (which is effectively the physical RAM size + pagefile size) which seems fairly graceful at first (no application crashes just yet, I might not even notice the problem for a while, it seemingly behaves more like some cache which is ready to shrink on demand) but eventually, when some applications tries to allocate fairly big amounts of memory (hundreds of megabytes) the system becomes progressively more unstable (it start to look more like a tradition memory leak which puts the whole system on it's knees).
    After closing (either voluntarily or involuntarily=crash) all applications which might contribute to this problem, the "leaking" stops but the memory is never freed (the commit size remains huge but it stops growing on it's own over time). A reboot is necessary to use the leaked memory again.

    WASAPI related speculation:
    I think I could narrow this issue down to two possible applications: MPC-HC and Foobar.
    After some brainstorming, I figured the common part is probably the audio (and I use both with WASAPI ecxlusive mode at that).
    I disabled the WASAPI exclusive mode in MPC-HC and it stopped leaking memory. I re-enabled the exclusive mode and I started loosing memory on a timer again.

    Since according to my knowledge, MPC-HC and Foobar don't share their WASAPI related code, the problem could be Windows itself or may be the sound driver.

    And I use the HDMI port of the GTX1070 for sound exclusively (the main-borad sound chip is disabled, I have no bluetooth headsets paired with this PC, so really nothing else but the VGA card...).

    So..., what do you think?
    Did anybody else notice this kind of memory leak with WASAPI while using HDMI/DP audio? Does it happen to you with other sound cards (AMD VGA, dedicated sound card, main-board sound, etc)?

    This thing started a few months ago. I updated to Win10 1809 a few days ago and I usually install every nVidia driver updates as they come, so this can't be narrowed down to a specific Win10 or nVidia driver version (unless I try to install very old drivers).
     
    Last edited: Sep 28, 2018
  2. Chastity

    Chastity Ancient Guru

    Messages:
    3,745
    Likes Received:
    1,668
    GPU:
    Nitro 5700XT/6800M
    With Foobar2000 I use DirectSound out since under Win10 it's also bit perfect.
     
  3. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    I doubt that. But very easy to check - if you can play any sound (in browser for example) while player plays then it is not bit perfect because OS`mixer is in place.
     
  4. janos666

    janos666 Ancient Guru

    Messages:
    1,653
    Likes Received:
    407
    GPU:
    MSI RTX3080 10Gb
    Just because it goes through a mixer doesn't mean it has to be altered in any ways (if the input and output formats are the same).
    I don't know the exact case here but it would be logical if it's the same as WDM for picture: just because every content in all windows go through the desktop compositor doesn't mean their colors always get altered (it can be be but not necessarily --- unless you use the HDR desktop mode which converts the legacy windows from sRGB to Rec2020 but that's another story... or the obvious way: if some GUI element casts a shadow on your photo viewer app, etc...).

    WASAPI exclusive mode has other convenient features: besides being able to automatically set up a matching bit depth and sample rate it can also set a matching channel configuration.
    And my AVR can automatically switch to "stereo" mode for 2-channel input (which is effectively a unique preset mode for stereo which can be configured independently from multi-channel input) and switch back to multi-channel mode later (which triggers a switch to another preset mode with different settings: different room acoustic calibration / room curve, different crossover frequency for the sub [or turn that sub on/off], etc...) It's not necessary for me (there are less convenient ways to achieve the same result) but it's good to have.

    However, besides of any workarounds, I guess this is a fairly serious bug anyway.
     
    Last edited: Sep 29, 2018

  5. Vidik

    Vidik Master Guru

    Messages:
    619
    Likes Received:
    220
    GPU:
    MSI 1070 Gaming Z
    @janos666 Tried WASAPI exclusive in AIMP using Focusrite Scarlett 2i2 audio interface and after 20 minutes memory usage stayed the same. So WASAPI is not to blame at least in my case. My 1070 is connected via DP but I disable "high definition audio controller" component in device manager as soon as I install windows, guess I won't be very helpful there.
     
  6. janos666

    janos666 Ancient Guru

    Messages:
    1,653
    Likes Received:
    407
    GPU:
    MSI RTX3080 10Gb
    Thanks, so that seems to narrow it down to the nVidia driver rather than WASAPI in general.
    I guess I should try to install the nV sound driver from a really old random driver package (since it's rarely updated) and see if it changes anything (although it won't help if a Windows update triggered an old driver bug).

    Edit: I tried older nV sound drivers (from 370 series) to no avail but conjured up another hypothesis: It's caused by running Firefox and MPC-HC at the same time. May be it's due to how Firefox is blocked from the sound device while mediaplayers hold exclusive access: anything that Firefox wants to pass to the sound mixer (even if the embedded videos are all muted by default) ends up in some kind of queue (probably at system level because closing Firefox doesn't release that part of the commit size but does shave off a lot [Firefox fully closes and can be relaunched without the "already running" warning]).

    Now who to complain to...? Mozilla or Microsoft? :( (I guess I can rule nVidia out for now.)
     
    Last edited: Sep 29, 2018
    Vidik likes this.
  7. Chastity

    Chastity Ancient Guru

    Messages:
    3,745
    Likes Received:
    1,668
    GPU:
    Nitro 5700XT/6800M
    I stream DTS encoded audio files to my external receiver often with Foobar2000. If it wasn't bitperfect, it wouldn't work. It's also been certified to be bitperfect on HA and foobar2000 dev team. Just make sure any "enhancements" are turned off for the driver.
     
    janos666 likes this.
  8. janos666

    janos666 Ancient Guru

    Messages:
    1,653
    Likes Received:
    407
    GPU:
    MSI RTX3080 10Gb
    But are applications able to switch the mixer format (bit depth and sampling rate) to match the content's format automatically? (It can't be bit-perfect otherwise. And most of my music archive is still 44.1KHz whereas pretty much all video is 48 or some multiple of that.)

    I see a fairly new option in MPC-HC (I didn't notice this before): "ignore system channel mixer". The text indirectly indicates it's for non-exclusive mode (it states that this doesn't matter with exclusive mode because that one always ignores the mixer anyway). But I am not sure what it does exactly (one should dig into the code or better yet figure it out by kitchen level reverse-engineering -> looks like I shall do that later...).

    But I am not aware if Foobar could do this (well, if MPC-HC can, then it should be possible but no idea if it's implemented and where to enable it).
     
  9. janos666

    janos666 Ancient Guru

    Messages:
    1,653
    Likes Received:
    407
    GPU:
    MSI RTX3080 10Gb
  10. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,606
    Likes Received:
    13,615
    GPU:
    GF RTX 4070
    Chastity was talking about bypassing DTS signal out to external receiver - not the mode when soundcard actually process the signal. He calls it bit-perfect.
     

  11. Astyanax

    Astyanax Ancient Guru

    Messages:
    17,040
    Likes Received:
    7,381
    GPU:
    GTX 1080ti
    bit streaming is interrupted by pcm sounds when the sound device is not exclusive, this can cut out the sounds on some receivers which don't provide low latency stream switching.

    In this case, mozilla's cubeb buffer doesn't handle sounds being 'dropped' leading to a leak in the parent process, this has been reported before even without the device being locked if a background tab plays a sound tone when the default background autoplay setting is in place.
     

Share This Page