1

Some of the applications / game i play have GPU memory leakage

The gpu memory used gets increased over time

Even after I close the game / apps gpu used memory is still there

When I disable GPU from device manager and enable back GPU memory is cleared

But I wonder if there is any software / command etc to flush GPU memory?

I have Geforce GTX 1050 Ti and I am using Windows 10

1
  • 1
    Have you looked into commands you can run that will disable and enable the GPU? Or, if the GPU driver has a command you can run that will flush the cache? This will be documented by the card manufacturer and so will be as available to you as it is to us. Commented Apr 23, 2022 at 3:34

4 Answers 4

3

If the graphics memory usage persists after closing the application, there's probably a graphics driver bug involved. Regular GPU programming APIs wouldn't help with that.

Windows offers a sort-off undocumented keyboard shortcut to quickly restart the graphics driver:

Win+Ctrl+Shift+B

Maybe that's enough of a workaround until updated drivers without the bug are released. Restarting the graphics driver may crash less resilient applications.

0

If it's your browser that's hogging the resources, there are typically internal page URI's that can trigger the release/refresh. For example, for Google Chrome, you can type into the omnibox: chrome://gpuclean and hit enter.

0

You can probably get a toggle off/on going though a powershell script like so.

  • Open Windows Powershell ISE and copy paste the following code into it
  {    
    #Disable the GPU   
    Get-PnpDevice -FriendlyName "GPU NAME" | Disable-PnpDevice
    
    #Adjust wait time to any amount you want
    Sleep -Seconds 5
    
    #Enable the GPU
    Get-PnpDevice -FriendlyName "GPU NAME" | Enable-PnpDevice
  }

  • Replace GPU NAME with the exact name of your GPU as seen inside device manager. This is the "Friendly Name". Not all commands work with friendly name though so you might need to use the -Deviceid argument instead of -FriendlyName and retrieve the Deviceid by right clicking > properties on the GPU inside device manager.

  • Save the script to your desktop and right click > run with powershell

If you get a Disable-PnpDevice : Generic failure error, you might have to run the script using administrator privileges.

  • Right click the Windows menu > Windows PowerShell (Admin).
  • Copy the full file path of the script and run & "[File Path]" in the Admin PowerShell terminal.
  • You might have to confirm the actions by entering Y.

This should now toggle your GPU off/on. For other ways to clear the ram cache you'll have to check out the NVIDIA development forum. There are some things you can script with NVIDIA GPU's. A few sample scripts should be available for you to check out here on your local C Drive:

C:\Program Files\NVIDIA Corporation\NVIDIA WMI Provider\Samples
-1

I have same issue for few months and looking for same answer. I think the VRAM usage is slowly increasing even on idle.

Also, on restart, the card is installed again, getting a new instance ID. I did rolled back the driver, but the issue remained.

I use this script, based on pnputil command, to find the instance ID matching Device Description and having the status Started, and do the toggle (using the same pnputil).

@echo off
setlocal enabledelayedexpansion
rem -params-
set select_field=Device Description
set select_value=3060
set instance_id=none
rem set "instance_id=PCI\VEN_10DE&DEV_2489&SUBSYS_88501043&REV_A1\4&1f822d9d&0&0008"
rem -params-end---change with care below this line

rem if ID is known, do the thing.
if /i "%instance_id%" neq "none" goto theThing
rem otherwise...
for /f "tokens=1,2 delims=:" %%A in ('pnputil /enum-devices /class Display') do (

    if "%%A" == "Instance ID" (
        rem if ID is not none breaks out
        if /i "!instance_id!" neq "none" goto forBreak
        set "tmp_id=%%B"
        )
    if "%%A" == "%select_field%" (
        for /f "tokens=* delims= " %%K in ("%%B") do set "value=%%K"
        rem delete from %value%  the search string 
        call set "test=%%value:%select_value%=%%"
        rem if it stays the same ramane it means it does not have it - thus try next instance_id
        if /i "!value!" == "!test!" (
            set value=none
            set instance_id=none
        ) else (
            set "instance_id=!tmp_id!"
            rem deletes the spaces from the beggining of the string (does not work with for because it contains "&" charcater)
            set "instance_id=!instance_id:~16!"
        )
    )
    rem if status is disconected sets the vars to none - so the loop continues
    if "%%A" == "Status" (
        set "test=%%B"
        set test=!test:Disconnected=!
        if /i "!test!" neq "%%B" (
            set value=none
            set instance_id=none
        )
    )
)
:forBreak
echo selected: %select_field% ~ %select_value% = %value%
echo found instance ID: !instance_id!
rem if not found
if /i "%instance_id%" == "none" (
    echo nothing found... see below:
    echo.
    pnputil /enum-devices /class Display
    echo.
    goto ending
)

rem check administrator elevation
net session >nul 2>&1
if not %errorLevel% == 0 (
    echo.
    echo -- Must be open with "Run as Administrator" -- 
    echo.
    goto ending
) 


:theThing
pnputil /disable-device "%instance_id%"
timeout 2
pnputil /enable-device "%instance_id%"

:ending
echo.
pause

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .