How to Fix: Brave Browser Slow (High CPU, RAM) Script

Dennis Faas's picture

Infopackets Reader Ted S. writes:

" Dear Dennis,

Thanks for your article on How to Fix: pbeagent.exe 100% CPU Usage (Kill, Respawn Script) and How to Fix: Block YouTube Ads (uBlock Origin Dead). I have a related question to both of those articles. Since I switched to Brave Browser a few months ago, I've noticed that after a while, Brave gets really slow and laggy - especially when I'm playing videos on YouTube.

For example: when I'm browsing Youtube and if I see a video I like, I will press CTRL + Left Click on the mouse to open the video I want to watch in a new tab. That way I can continue scrolling my main Youtube feed and have all the videos I want to watch in a separate tabs. However, when Brave is slow, it takes a while for the new tab to appear.

At this point, I usually look at my Task Manager and I see at least one or two Brave.exe processes that are eating up 1.5 - 2+ GB of memory. To fix Brave's high memory usage (which is the reason why Brave slows down), I have to close Brave, wait minute or two for all the brave.exe processes in Task Manager to relinquish their massive memory usage, then launch Brave again. Once I do that, Brave is back up and running nice and fast. Since you offer remote desktop support, I am willing pay you to write a script that will automatically launch Brave at 6 AM every day as a way to 'refresh' Brave browser every 24 hours so I don't have to keep closing it and reloading it. Thanks for all you do. "

My response:

I asked Ted if he would like me to review the issue using my remote desktop service, and he agreed.

Below I will discuss my findings.

How to Fix: Brave Browser Slow (High CPU, RAM) Script

After some testing and tweaking, here is the script I wrote to fix Brave's high memory usage and to fix the lag. Here's how it works: when the script launches, it gracefully closes the brave.exe task, then it goes into a loop to check to see if brave has actually exited memory. Once it does, it waits a few more seconds, then launches the brave browser again.

Important:

a) if you want to use the script below, you will need to make sure Brave resumes all its tabs where it left off so you don't lose what you were previously browsing. You can set this under Brave -> Menu (top right corner) -> Settings -> Get Started (menu) -> On Startup -> Continue where you left off.

b) you need to set Brave is the default browser due to the way the script launches Brave (i.e.: start "" "explorer.exe" "https://"), otherwise it will launch another browser. The reason it is launched like this is because links in emails won't launch Brave due to the way that links are handled. To set Brave as default, launch Brave, then click Settings from the menu (top right corner) -> Get Started -> Make Brave your default browser.

Here is the script:

  1. Use your mouse to highlight the text below, then right click over top of the highlighted text and select Copy from the dialogue menu.

    REM Brave close and relaunch script by Dennis Faas, infopackets.com
    REM save the script to a .bat file, then run it every 24 hours to keep Brave fresh and lag-free

    @echo off
    setlocal

    REM Set the path to Brave executable here
    set "BRAVE_PATH=C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"

    echo Attempting to gracefully close Brave browser...
    powershell -Command "Get-Process brave* -ErrorAction SilentlyContinue | ForEach-Object { $_.CloseMainWindow() | Out-Null }"

    REM Wait for Brave to fully shut down
    echo Waiting for Brave to exit...
    :WAITLOOP
    timeout /t 2 >nul
    tasklist /fi "imagename eq brave.exe" | find /i "brave.exe" >nul
    if %errorlevel%==0 (
    goto WAITLOOP
    )

    REM 3-second delay before relaunching
    echo Brave has exited. Waiting 3 seconds before relaunching...
    timeout /t 3 >nul

    REM relaunch brave assuming it is default browser
    REM we launch it this way so http and https links are registered to open in Brave
    echo Relaunching Brave...
    start "" "explorer.exe" "https://"

    endlocal
    exit /b
    echo this is a dummy line
     
  2. Click Start, then type in "Notepad" (no quotes); wait for Notepad to appear, then right click it and select "Run as Administrator".
     
  3. In Notepad, click Edit -> Paste. The script you copied in Step #1 should appear in notepad.
     
  4. In Notepad, click File -> Save As, then save the file as (with quotes): "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave_restart.bat"
     
  5. Now it's time to test the script. Launch Brave if you haven't already, then launch a command prompt. To do so, click Start, then type in "cmd.exe" (no quotes); wait for cmd.exe or Command Prompt to appear in the list, then right click and run as Administrator.

    Highlight the text below in including the quotes:

    "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave_restart.bat"
    echo this is a dummy line

    Right click over the highlighted text and select Copy. Next, go to the command prompt window you just opened up, then right click in the middle of the window and the text you just highlighted should output and the script should execute. The Brave browser should exit if the script executed properly.
     
  6. Assuming the script is working, now it's time to add it to Task Scheduler at 6am every day.

    Click Start, then type in "task scheduler" (no quotes); wait for Task Scheduler to appear in the list and click it.

    On the left hand side of the window near the top of Task Scheduler, right click Task Scheduler Library and select "Create Task".

    In the General tab and next to the "Name" heading, enter in: restart brave at 6am, and IMPORTANT: select "Run only when user is logged on", "Run with highest privileges", and "Hidden".

    In the Triggers tab, click New, then under the "Settings" heading, select Daily, and Start: current date, and 6:00 AM. Under Advanced Settings, make sure "Enabled" is selected.

    In the Actions tab, click the Browse button and input with quotes: "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave_restart.bat"

    In the Settings tab, only have "Allow to run on demand" selected.

    Click OK.
     
  7. Now it's time to test to see if the batch file is working under Task Scheduler. Launch Brave browser again, then go to the Task Scheduler window. Look for "restart brave at 6am" task and right click it, and run it. The brave browser should close and relaunch and you will know it's working.

I hope that helps.

One important caveat to mention here: don't leave any forms on your browser (such as a submission form, comment form, etc) in an unfinished state (i.e., the form was not submitted), or you will lose anything you input into a form when the browser is restarted every day.

Got More Tech Questions? Ask Dennis!

I can fix most problems remotely using my remote desktop support. Or, if you have a simple tech question you'd like me to answer like the one above, send me an email through the contact page and I'll consider writing an article about it.

About the author: Dennis Faas is the CEO and owner of Infopackets.com. Since 2001, Dennis has dedicated his entire professional career helping others with technology-related issues with his unique style of writing in the form of questions-and-answers; click here to read all 2,000+ of Dennis' articles online this site. In 2014, Dennis shifted his focus to cyber crime mitigation, including technical support fraud and in 2019, online blackmail. Dennis has received many accolades during his tenure: click here to view Dennis' credentials online DennisFaas.com; click here to see Dennis' Bachelor's Degree in Computer Science (1999); click here to read an article written about Dennis by Alan Gardyne of Associate Programs (2003). And finally, click here to view a recommendation for Dennis' services from the University of Florida (dated 2006).

Rate this article: 
Average: 5 (6 votes)