Why is my brand new laptop running C programs super slow in VS Code?
Asked by
Octave
I recently got an HP Victus with an i7 13th Gen CPU, 24GB of RAM, and a 1TB SSD, so I expected everything to be super fast. I'm trying to set up VS Code for C programming with GCC/MinGW. I wrote a simple program that just reverses a word using arrays, and it shouldn't be complex at all. However, when I try to run it, VS Code takes over 400 seconds to execute (if it doesn't freeze or crash with exit code=1). I've already tried a bunch of things, including uninstalling Code Runner, moving my files out of OneDrive, running VS Code as admin, using both Command Prompt and PowerShell, compiling directly from the terminal instead of using the Run button, cleaning up tasks.json, and double-checking my code. Despite all that, the problem persists. It's clearly not a hardware issue since the laptop is new and high-spec. I'm hoping someone here has experienced a similar problem and knows what might fix it because I'm tired of this wait time.
Answers
If you're running into a lot of issues with GCC on Windows, I recommend trying WSL2 (Windows Subsystem for Linux). It's often a smoother setup for C programs. Or, you might find MSVC in Visual Studio Community Edition to be a better experience over GCC in VS Code.
Reply to this answer
What version of VS Code are you using? Sometimes issues arise from the Insiders build. Make sure youโre on the stable version.
Reply to this answer
Have you tried running your code directly from the terminal? It's usually a good way to see if the issue is with VS Code itself or your setup. If it runs instantly there, then VS Code might be the culprit.
Octave: Yeah, it runs perfectly from the terminal, no issues at all. Itโs only when I hit the Run button in VS Code that it lags.
Reply to this answer
Double-check where your compiler is installed. If it's still in OneDrive, move it out. That could significantly impact performance.
Octave: I already moved everything out of OneDrive, so that shouldn't be causing the delay.
Reply to this answer
Watch out for antivirus softwareโsometimes it can cause really slow compilation times because it scans files as theyโre opened. Itโs unlikely to explain why command line runs fine, but itโs worth checking if you have any such software installed.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Octave: I'm using the normal version of VS Code, not the Insiders build.