Ways to Improve Visual Studio 2019 Performance
Use a 64-bit OS
If you upgrade your system from a 32-bit version of Windows to a 64-bit version, you expand the amount of virtual memory available to Visual Studio from 2 GB to 4 GB. This enables Visual Studio to handle significantly larger workloads, even though it is 32-bit process.
Disable automatic file restore
Visual Studio automatically reopens documents that were left open in the previous session. This can prolong the times it takes to load a solution by up to 30% or more, depending on the project type and the documents being opened. Designers like Windows Forms and XAML, and some JavaScript and typescript files, can be slow to open.
Visual Studio notifies you in a yellow bar when automatic document restore is causing a solution to load significantly slower. You can disable automatic file reopening by following these steps:
Select Tools > Options to open the Options dialog box.
On the Projects and Solution > General page, deselect Reopen documents on solution load.
Configure debugging options
If you are typically running low on memory during debugging sessions, you can optimize performance by making one or more configuration changes.
Enable Just My Code
The simplest optimization is to enable the Just My Code feature, which only loads symbols for your project. Enabling this feature can result in a significant memory saving for debugging managed applications (.NET). This option is already enabled by default in some project types.
To enable Just My Code, choose Tools > Options > Debugging > General, and then select Enable Just My Code.
Disable Diagnostic Tools
It is recommended that you disable CPU profiling after use. This feature can consume large amounts of resources. Once CPU profiling is enabled, this state is persisted across subsequent debug sessions, so it’s worth explicitly turning it off when done. You may save some resources by disabling the diagnostic tools while debugging if you do not need the provided features.
To disable the Diagnostic Tools, start a debugging session, select Tools > Options > Debugging > General, and then deselect the Enable Diagnostic Tools while debugging option.
Disable tools and extensions
Some tools or extensions can be turned off to improve performance.
Tip
You can often isolate performance issues by turning off extensions one at a time and rechecking performance.
Managed language service (Roslyn)
Disable full solution analysis
Visual Studio performs analysis on your entire solution in order to provide a rich experience about errors before invoking a build. This feature is useful to identify errors as soon as possible. However, for large solutions, this feature can consume significant memory resources. If you’re experiencing memory pressure or similar issues, you can disable this experience to free up these resources. By default, this option is enabled for Visual Basic and disabled for C#.
To disable Full Solution Analysis, choose Tools > Options > Text Editor, then select either Visual Basic or C#. Choose Advanced and deselect Enable full solution analysis.
Disable CodeLens
Visual Studio performs a Find All References task on each method as it is displayed. CodeLens provides features such as the inline display of the number of references. The work is performed in a separate process such as ServiceHub.RoslynCodeAnalysisService32. In large solutions, or on resource-constrained systems, this feature can have a significant impact on performance. If you’re experiencing memory issues, for example, when loading a large solution on a 4-GB machine, or high CPU usage for this process, you can disable CodeLens to free up resources.
To disable CodeLens, choose Tools > Options > Text Editor > All Languages > CodeLens, and deselect the feature.
Other tools and extensions
Disable Extensions
Extensions are additional software components added to Visual Studio that provide new functionality or extend existing functionality. Extensions can often be a source of memory resource issues. If you’re experiencing memory resource problems, try disabling extensions one at a time to see how it impacts the scenario or workflow.
To disable extensions, go to Extensions > Manage Extensions, and disable a particular extension.
Disable map mode
Map mode displays lines of code, in miniature, on the scroll bar. Map mode is enabled by default.
To disable map mode, go to Tools > Options > Text Editor > All Languages > Scroll Bars, and in the Behavior section, deselect the Use map mode for vertical scroll bar option.
Disable word wrap
Word wrap displays the portion of a long line of code that extends beyond the current width of the code editor window. Word wrap is on by default.
To disable word wrap for a project that you are currently working on, go to Edit > Advanced > Word Wrap. (You can toggle this setting by using the same menu commands.)
To disable word wrap for all projects, go to Tools > Options > General > Text Editor > All Languages > General, and in the Settings section, deselect the Word wrap option.
Disable XAML Designer
The XAML designer is enabled by default, but only consumes resources if you open a .xaml file. If you work with XAML files but do not wish to use the designer functionality, disable this feature to free up some memory.
To disable XAML Designer, go to Tools > Options > XAML Designer > Enable XAML Designer, and deselect the option.
Remove workloads
You can use the Visual Studio Installer to remove workloads that are no longer used. This action can streamline the startup and runtime cost by skipping packages and assemblies that aren’t needed anymore.
Force a garbage collection
The CLR uses a garbage collection memory management system. In this system, sometimes memory is used by objects that are no longer needed.
To force a garbage collection, use the hotkey: Ctrl+Alt+Shift+F12, Ctrl+Alt+Shift+F12 (press it twice).
Comments
Post a Comment