VS 2015 High CPU Usage on File Save - c#

With Visual Studio 2015 I have noticed that if I have multiple solutions open with a common project to all solutions, if I so much as edit and save one .cs file belonging to the common project, all Visual Studio 2015 instances will consume CPU for 10-15 seconds. Note that the common project is fairly large.
I don't recall this happening with Visual Studio 2013. It is common in my workflow to have 8-9 instances of Visual Studio open all with solutions referencing the common project, so I feel as though I would have noticed this behavior with Visual Studio 2013 (my development machine has 32 GB of RAM which makes this type of workflow possible).
I have tried:
Disabling CodeLens
Uninstalling ReSharper
Disabling the four C# Intellisense features found in Tools->Options
Temporarily Disabling Static Code Analysis Solution Wide (for all loaded solutions)
I also launched a separate instance of Visual Studio 2015, enabled Microsoft Symbol Servers and profiled (via Debug-> Profiler-> Performance Explorer -> Attach/Detach) an offending Visual Studio instance while it was consuming High CPU.
This image shows the profiler summary and you can see from the graph high CPU usage between ~12s and ~27s.
84.46% of the samples were in Thread::intermediateThreadProc, and the majority were exclusive samples, but of the inclusive samples, it appears as though it was doing some sort of code analysis.
With this information I assume that some sort of background code analysis is being performed with all Visual Studio 2015 instances (including those in the background). Does anyone know how to disable this? Or if my assumption is incorrect, any other suggestions?
Update 9/12/2015
Interestingly, if I perform the same profiling with ReSharper 9.2 installed, I get a similar result, but with JetBrains.Platform.Satellite.exe at the root of the "Hot Path" (instead of devenv.exe).
Update 10/11/2015
I believe this is the issue:
How to disable real time compilation in Visual Studio 2015
Is there a way to disable real time compilation on save? Or at least have it not be so intrusive? The operation most likely to follow "Save" is "Build", and because all of the visual studio instances are recompiling their respective solutions (without being asked), the "Build" operation in the active solution is severely hindered.

Found here (http://www.itgo.me/a/x8021838007883560399/how-to-disable-real-time-compilation-in-visual-studio-2015) :
"go to tools, options, text editor, C#, Advanced and uncheck Enable full solution analysis. This should stop your problem as the solution won't be checked every time unless you build it."

Related

Visual Studio 2015 diagnostic tools no longer working

I have Visual Studio 2015 Community Edition Update 3 running on Windows 7 SP1 64 bit, which I use to develop C# applications.
I love the diagnostic tools during debugging to spot performance problems early on. However, they stopped working for me sometime in the last month or so (possibly related to installing Update 3, although I have no information to back that up). I see the error message "CPU Profiling while debugging is not available on this version of Windows. To see CPU usage details, run the CPU Usage tool without the debugger (Debug -> Performance Profiler...)."
Things I have tried without success:
Completely uninstalling and reinstalling VS.
Performing a repair on my VS installation
Ensuring "Use {Managed,Native} compatability mode" is disabled in debug options.
Enabling the Diagnostics Hub logging info as described in this question. No error messages that I can see appear in the logs.
This still happens even if I create a new WPF project, so I don't believe it has any project-specific cause.
Are there any other things I can try? Obviously they were working before, so I don't believe the error message about my version of Windows being unsupported.
Deleting my solution's .suo (solution options) file fixed the issue. My initial statement of this bug affecting even new projects seems to be wrong. Although, I did do a complete reinstall of VS after doing that test, so it's possible that impacted the outcome.
Full disclosure: I work at Microsoft, specifically on the Diagnostic Tools team.
There are parts of the Diagnostic Tools that won't work on Windows 7, specifically taking a CPU profiling trace while debugging. This is a limitation of the operating system and ETW. If you are just interested in the graphs and debugging events, those should work. You can turn on logging for our tools which might give you some insight into why they are not working:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\DiagnosticsHub\LogLevel
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\DiagnosticsHub\LogDirectory
For LogLevel you can use one of the following strings "All", "Info", "Debug", "Warning", "Error" (In your case I would use All to better see what is happening). As for LogDirectory it is a directory of your choice "C:\Logs". When your done reproing the scenario, close VS to flush the logs and don't forget to delete these keys as the diagnostic tools logging is pretty system intensive.
You should be able to search for "Error ---" in the logs to get an idea of what is happening. We have seen problems with certain VS extensions and custom projects.
Also, feel free to also post the issue at: https://connect.microsoft.com/ Each issue that is received there gets turned into a bug and assigned to the corresponding team.
I had som issues with that a while ago.
1) Check Tools>Options>Debugging>General>Enable Diagnostic Tools while debugging
2) Check Tools>Options>Intellitrace>Enable intellitrace
I had the same issue, although deleting the .suo file did not help, I also repaired Visual Studio 2015 Professional and then it worked. So for future readers, if deleting the .suo does not help, try to also repair Visual Studio and vice versa.
None of the others worked for me. What I had to do was close all Visual Studios and re-opened it and the diagnostic tool worked.
(I deleted the .suo file, made sure all the correct options were enabled, but because I had another Visual Studios session running, none of it worked until I closed all)
I had already another visual studio instance running with diagnostic one. That was the issue for me.
I faced this problem today and it was not easy to find working solution.
This helped to me:
Reinstall Cumulative Servicing Release for Microsoft Visual Studio 2015 Update 3 (KB3165756)
Direct link to download: http://go.microsoft.com/fwlink/?linkid=816878.
After Repair action (I had it installed before, otherwise install) prompted to restart computer, did it and Diagnostic tools worked again.
I had a similar problem with Visual Studio 2015 Pro Update 3 running on Windows 10 Home. The runtime display of memory and cpu usage stopped working. Deleting the .suo file fixed the problem, as indicated by proc-self-map's answer. The .suo file was buried in the .vs hidden directory so I removed the whole .vs subdirectory. Now the runtime display of memory and cpu usage works like a charm again. No reinstall required.

Visual Studio 2015 is extremely slow

I have installed Visual Studio 2015 Professional Edition, and my computer specs are Intel i7-3770 CPU 3.40 GHz, 8 GB RAM, and Windows 7 Enterprise 64-bit.
I want to upgrade my project to .NET 4.6 which is written in Visual studio 2005 .NET 2.0, but I have a serious problem about speed. After I open my project (huge project) in Visual Studio 2015 it is going crazy. Building, debugging, opening menus are too slow. Sometimes I got "not responding" message. Is it about Windows 7 or can you give me any advice about my speed problem?
You can try to apply the following steps:
Go to menu Tools → Options → Source Control and set Current source control … to None
Go to menu Tools → Options → Environment (or Accounts) → Synchronized Settings and remove this option by unchecking the checkbox.
Clean the contents in the following cache folders (do not delete these folders, instead delete their contents only) and restart Visual Studio:
Clean the content in WebSiteCache folder (can be found in C:\Users%USERNAME%\AppData\Local\Microsoft\WebSiteCache)
Clean the content in Temporary ASP.NET Files folder (can be found in C:\Users%USERNAME%\AppData\Local\Temp\Temporary ASP.NET Files)
Note: If you have Hardware Acceleration enabled or if you use the default Visual experience settings in Microsoft Visual Studio 2015 or Visual Studio 2013, you might experience intermittent performance issues, product crashes, or rendering issues. In order to work around these issues, go to menu Tools → Options → Environment → General and apply the following settings:
For more information, visit You experience performance issues, product crashes, or rendering issues in Visual Studio 2015 and Visual Studio 2013.
If the problem is related to debugging, try the workaround on Visual Studio debugging/loading very slow.
This site contains some useful tips on how to improve the Visual Studio performance, disabling features for large solutions. For example:
Go to Tools -> Options -> Text Editor -> C# -> Advanced and uncheck Enable full solution analysis
Go to Tools -> Options -> XAML Designer -> General and uncheck Enable XAML Designer (requires restart of Visual Studio)
Go to Tools -> Options -> Text Editor -> All Languages and uncheck Enable CodeLens
Go to Tools -> Options -> Debugging -> General and disable Enable Diagnostic Tools while debugging
I have a large project and have experienced these kinds of slow downs too. I've improved the performance to an acceptable level by changing the scope of the Error List window to Current Document.
I also get improvements by changing from Build + IntelliSense to Build Only. But because I find the IntelliSense useful, I compromised to keeping Build + IntelliSense and scoping to Current Document.
I have found that removing the ".vs" folder from your solution folder greatly increases editor speed if it becomes slow over time. It is a hidden folder in the root directory of your solution. I would recommend saving a backup of it just in case you need to revert. As far as I know, it holds user specific settings for the solution such as the .suo file as detailed here. You can try just removing the .suo file too. These folders/files will be regenerated by VS the next time you open and close that solution.
The Windows Defender Antimalware can cause Visual Studio to lag. As mentioned by Nostradamus in this answer:
Go to Update & Security -> Settings -> Windows Defender. Open the Defender and in the Settings selection, choose Exclusions and add the "devenv.exe' process.
Another thing I did was update ReSharper and every addon to the latest update.
I also noted that several processes called Microsoft Compatibility Telemetry, CompatTelRunner.exe was using a lot of CPU when I used Visual Studio. I disabled "Feedback and diagnostics" by following this guide.
It worked for me!
Is it possible that you were trying to do different operations on solution at the same time? In my situation, the problem appeared because I was trying to open solution, while there was a process from TFS, which was trying to get latest version. Some kind of lock happened.
Safest way I thought of was to restart the system, delete .suo file and it worked for me.
What else: check if your visual studio version is 64bit on 64bit system, I have uninstalled some team foundation power tools and it screwed with my VS, it produced the same problems
Make sure you're not working on a solution that's on a network drive.
Seems like such an obvious thing, but I missed it, and VS gives you precisely no hints as to the problem, it's just lots of "Not Responding...".
For me the culprit was Resharper cache, simply clear Resharper cache and it works fine
I suggest the quickest and easier performance enhancement (for C#) is to replace VS 2015/2017 with VS2013.
C# is largely unchanged between versions. It just takes twice as long to use 2015/2017 and I am sure I am not the only one to waste time using later (better)compilers only to have to revert.
I do not think it is unreasonable to expect to use a compiler straight out of the box. You can with 2013.
Microsoft MUST ensure VS2019 is at least as fast as 2013 (for C#)

Visual Studio 2013 or 2015 EditorPackage did not load correctly constantly

When starting Visual Studio 2013 Pro (Update 4 installed) I very often get this error message (several times a day now) for the past about two weeks:
The 'Microsoft.VisualStudio.Editor.Implementation.EditorPackage' package did not load correctly.
I know I can correct this problem by closing Visual Studio and deleting:
%LocalAppData%\Microsoft\VisualStudio\12.0\ComponentModelCache
I have never seen it before that time and as far as I found out in the Internet it was possibly introduced with Update 3.
Well, the problem is that it is annoying to restart Visual Studio several times a day, and I was wondering if anyone else is experiencing this and knows how to solve it for good or what the cause is.
I noticed that it happens extremely often if I work in more than one instance of Visual Studio in parallel. This one is a killer. But still I suspect a third-party component to be involved or it is the size of one of the solutions (about 70 projects). I tried to deactivate some extensions I newly installed and need for the big project, but to no avail.
Just as information: I am working with C#. When working in parallel with projects open in several instances of Visual Studio I never had problems before.
Does anyone have the same problem to this extend or possibly have a better solution than deleting the folder and restarting?
This has become a popular question so I thought I add an explicit answer how to (at least) temporarily fix the problem as already stated in the question:
I stop Visual Studio and delete the following folder (completely, not just contents)
%LocalAppData%\Microsoft\VisualStudio\12.0\ComponentModelCache
If you are using VS2015, then the path should be:
%LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
If you are using VS2017, then the path should be:
%LocalAppData%\Microsoft\VisualStudio\15.0\ComponentModelCache
I don't keep a backup of the folder. It is created automatically again when starting Visual Studio.
I have never found a solution how to permanently fix the problem in that working environment. In my new developing environment (new projects and new workplace) the problem never happens.
This is what helped me... seemed to happen after Windows Server 2012 SP install...
https://connect.microsoft.com/VisualStudio/feedback/details/1123745/setsite-failed-for-package-microsoft-visualstudio-editor-implementation-editorpackage
devenv /clearcache
devenv /updateconfiguration
In that case you can start Visual Studio setup again and choose the option showing two options, Repair and Uninstall. Then click Repair and when repair is done, restart the computer. Then the issue has been resolved.

ReSharper slowing down VS 2010

I love the ReSharper features but when I installed it onto my project on my laptop VS2010 is running a lot (read unusable) slower:
Stats are
Windows 7
4GB RAM
Intel 2 Core Duo # 2.00GHz
VS 2010
ReSharper 6.1
32 Bit Architecture
I'm assuming this should be enough to run the program so possible reasons I can think of are
other plugins causing conflicts / overloading VS
too many ReSharper errors (it's old code so will need cleaning)
Does anyone else have suggestions as to what this could be?
EDIT: the solution is 15 separate projects with 20 - 30 cs files. Some are very large (antlr generated)
EDIT: After turning off the 'solution wide analyse feature' the memory usage is down to 500Mb and it's running fine.
I sometimes need to open old projects where there are many big files with resharper errors.
My solution is to exclude these files from the resharper analysis ("Edit items to skip" under the Code inspection settings).
I lose some intellisense but VS becomes usable again. If I need to do a lot of work in one of these big files I enable them one by one.
ReSharper tends to bloat memory usage of Visual Studio (check devenv.exe under the Processes tab in Task Manager). If you have a solution containing many projects, and are running lots of other things on your PC you may find that memory is being swapped to disk a lot.
Possible solutions:
Get more RAM
Run fewer programs at once
For me I was using Resharper with Visual Studio 2013 with 30+ projects, and even disabling solution-wide analysis in addition to Ultimate Guide were not good enough in total. I have 16GB RAM - so memory was probably not the issue.
Resharper does not scale up that well with increasing number of projects.
How I fixed those issues were (in addition to the Ultimate Guide (suggestions there are great))
Unload any projects that are not directly related
Edit items to skip as Adrianm suggested
Go to Resharper Menu => Options => CodeInspection => Inspection Severity. Go to your programming language (C# for me). Among the options there you will see many inspection severities for different issues (a few hundreds). Most of them I did not care, some of them I used very frequently. I set the severity to "Do not show" for many of the severities that I did not care.
Since Resharper also had reduced performance after a while, and I really had some suo settings that I liked in my solution (some less frequent projects unloaded, debug exceptions enabled etc.), I took a backup of them. First delete the suo file (user settings) in the solution folder. After that set the settings you want in Visual studio, and click save all. After that take a backup for that suo file. Every time resharper slows, if suspend/resume does not help, I close the solution, delete the current suo file, restore the suo file from the backup and start the solution back again.
All those steps now are providing me a very good pleasant Resharper performance with my Visual studio. It helps to invest as early as you can. Especially for item 3 when you think about it you are actually running many checks in parallel that you do not care about.
I know this is an older thread - yet the portions I wrote here are kind of independent from Visual Studio and Resharper version and I could not find this anywhere else on the web.
Hope it helps to anyone seeing similar performance issues with Resharper.
Edit 1: Btw - once you have that working it helps to get a backup of the resharper settings in case they get lost. If you are sharing the project among multiple developers, putting it to git/SVN might be a good idea as well.

Resharper throws OutOfMemoryException on big solution

IDE Configuration:
Visual Studio 2008 + Resharper 4.5.1 + Agent Smith 1.1.8.
There is no any sophisticated configuration for last to add-ins.
Solution description:
33 class libraries + web site with 200+ pages.
Symptoms: After an hour of work under tuned on Resharper the IDE starts to throw the OutOfMemoryExection exceptions. Normal work is impossible only reopen Visual Studio can help.
Does anybody has such problem? Is it possible to configure Resharper to consume less memory? What Resharper feature does consume the most memory?
Welcome to the World of ReSharper. This lesson is called, "You get what you pay for".
Various features of ReSharper do require knowledge of your entire solution. This information takes memory. The solution-wide analysis may be the most memory-intensive, but even changing the signature of a public method requires knowing all the code that calls that method.
One thing you can do sometimes is to use smaller, "sub-solutions". If you are refactoring your DAL layer for instance, you only need the DAL and any unit test projects. What I sometimes do is to select the solution in Solution Explorer and use File->Save Solution As to save it with a different name in the same folder. I then remove projects until I'm left with those I want. Do not save the projects you're removing (save them before you start). When you've got the set you want, just do a Save All.
If it becomes too much of an annoyance, you can also get ReSharper to display the memory usage in the status bar. That feature has been available for a long time.
If you're on 64-bit Windows (or you're happy to run 32-bit Windows with the /3GB switch), then you can configure Visual Studio to be /LARGEADDRESSAWARE, which, rather than 2GB, will give it 4GB (or 3GB on /3GB) of address space to play with.
See, for example, http://old.stevenharman.net/blog/archive/2008/04/29/hacking-visual-studio-to-use-more-than-2gigabytes-of-memory.aspx, which gives the following:
editbin /LARGEADDRESSAWARE devenv.exe
Also, see the JetBrains page on the topic: http://www.jetbrains.net/confluence/display/ReSharper/OutOfMemoryException%2BFix
I have seen this and similar problems in the past with earlier versions of Resharper (and other similar add-ins) and large solutions, and is one of the reasons I try to stay away from them. The only solutions I know of were to restart Visual Studio, uninstall Resharper, or keep it turned off except for when you really need to use it.
For what it's worth, Visual Studio 2010 should help with these types of problems.

Categories

Resources