Visual Studio slowdown because Virus & Threat protection Windows Defender Antivirus is scanning this file
I noticed that if I hit F5 to build and debug some code for a very small solution (1-5 small projects), there was a long delay of about 10-15 seconds. This seemed very unusual: I was expecting near instantaneous response.
If I change a single file and do a Build (without running), the build completes quickly, taking advantage of incremental build in managed and native compilers.
If I hit F5 to run the app (the first time after build, the delay occurs), stop debugging, and hit F5 again (without changing any code and thus no change in the running binary), the 2nd time is much faster (2-3 seconds).
So… the long delay occurred only the first time a build changes the binary.
I tried to see what was going on and learned that if I disabled Real time Virus protection for the folder into which my binaries are built, then the delay is gone.
Once the file has been scanned and deemed without a virus, the 2nd time running “remembers” the result and is much faster.
While writing code, many developers repeat a few steps:
1. Make a code change,
2. Build and run the code
3. Ensure the code runs as expected
For some smaller projects, sometimes that loop takes 1-2 seconds. If there’s a 12 second delay for virus scanning the newly built executable code, then that’s a significant productivity slowdown.
I’ve observed these delays on other folk’s machines too.
Slowdowns due to AntiVirus are probably in many AV products. Thankfully, there’s a workaround: you can add a folder to an “Exclusion List”
Once I did that, the long delay was gone.
BTW, Edit and Continue (even in C++) is a really good feature to avoid stopping/starting debugging). When you reach a break point you can modify your code, Set Next Statement (change the next statement that gets executed) if necessary, and continue running the newly modified code.
Virus & threat protection Windows defender antivirus is scanning this file
visual studio virus & threat protection windows defender antivirus is scanning this file your it administrator requires a security scan of this item. The scan could take up to 10 seconds