/// <summary> /// Called by the Visual Studio Shell to notify components of a broadcast message. /// </summary> /// <param name="msg">The message identifier.</param> /// <param name="wParam">First parameter associated with the message.</param> /// <param name="lParam">Second parameter associated with the message.</param> /// <returns>S_OK always.</returns> public int OnBroadcastMessage(uint msg, IntPtr wParam, IntPtr lParam) { switch (msg) { case VSConstants.VSM_VIRTUALMEMORYLOW: case VSConstants.VSM_VIRTUALMEMORYCRITICAL: { if (!_alreadyLogged) { // record that we had hit critical memory barrier Logger.Log(FunctionId.VirtualMemory_MemoryLow, KeyValueLogMessage.Create(m => { // which message we are logging and memory left in bytes when this is called. m["MSG"] = msg; m["MemoryLeft"] = (long)wParam; })); _alreadyLogged = true; } _workspaceCacheService?.FlushCaches(); // turn off full solution analysis only if user option is on. if (ShouldTurnOffFullSolutionAnalysis((long)wParam)) { // turn our full solution analysis option off. // if user full solution analysis option is on, then we will show info bar to users to restore it. // if user full solution analysis option is off, then setting this doesn't matter. full solution analysis is already off. _workspace.Options = _workspace.Options.WithChangedOption(RuntimeOptions.FullSolutionAnalysis, false); if (IsUserOptionOn()) { // let user know full analysis is turned off due to memory concern. // make sure we show info bar only once for the same solution. _workspace.Options = _workspace.Options.WithChangedOption(RuntimeOptions.FullSolutionAnalysisInfoBarShown, true); _workspace.Services.GetService <IErrorReportingService>().ShowErrorInfo(ServicesVSResources.FullSolutionAnalysisOff, new ErrorReportingUI(ServicesVSResources.Reenable, ErrorReportingUI.UIKind.Button, () => _workspace.Options = _workspace.Options.WithChangedOption(RuntimeOptions.FullSolutionAnalysis, true)), new ErrorReportingUI(ServicesVSResources.LearnMore, ErrorReportingUI.UIKind.HyperLink, () => BrowserHelper.StartBrowser(new Uri(LowVMMoreInfoLink)), closeAfterAction: false)); } } // turn off low latency GC mode. // once we hit this, not hitting "Out of memory" exception is more important than typing being smooth all the time. // once it is turned off, user will hit time to time keystroke which responsive time is more than 50ms. in our own perf lab, // about 1-2% was over 50ms with this off when we first introduced this GC mode. GCManager.TurnOffLowLatencyMode(); break; } } return(VSConstants.S_OK); }
/// <summary> /// Called by the Visual Studio Shell to notify components of a broadcast message. /// </summary> /// <param name="msg">The message identifier.</param> /// <param name="wParam">First parameter associated with the message.</param> /// <param name="lParam">Second parameter associated with the message.</param> /// <returns>S_OK always.</returns> public int OnBroadcastMessage(uint msg, IntPtr wParam, IntPtr lParam) { switch (msg) { case VSConstants.VSM_VIRTUALMEMORYLOW: case VSConstants.VSM_VIRTUALMEMORYCRITICAL: { if (!_alreadyLogged) { // record that we had hit critical memory barrier Logger.Log(FunctionId.VirtualMemory_MemoryLow, KeyValueLogMessage.Create(m => { // which message we are logging and memory left in bytes when this is called. m["MSG"] = msg; m["MemoryLeft"] = (long)wParam; })); _alreadyLogged = true; } _workspaceCacheService.FlushCaches(); // turn off full solution analysis if ((long)wParam < MemoryThreshold && _workspace.Options.GetOption(InternalFeatureOnOffOptions.FullSolutionAnalysisMemoryMonitor) && _workspace.Options.GetOption(RuntimeOptions.FullSolutionAnalysis)) { _workspace.Services.GetService <IOptionService>().SetOptions(_workspace.Options.WithChangedOption(RuntimeOptions.FullSolutionAnalysis, false)); // let user know full analysis is turned off due to memory concern // no close info bar action _workspace.Services.GetService <IErrorReportingService>().ShowErrorInfo(ServicesVSResources.FullSolutionAnalysisOff, () => { }); } // turn off low latency GC mode. // once we hit this, not hitting "Out of memory" exception is more important than typing being smooth all the time. // once it is turned off, user will hit time to time keystroke which responsive time is more than 50ms. in our own perf lab, // about 1-2% was over 50ms with this off when we first introduced this GC mode. GCManager.TurnOffLowLatencyMode(); break; } } return(VSConstants.S_OK); }
public int OnBroadcastMessage(uint msg, IntPtr wParam, IntPtr lParam) { switch (msg) { case VSConstants.VSM_VIRTUALMEMORYLOW: case VSConstants.VSM_VIRTUALMEMORYCRITICAL: { if (!_alreadyLogged) { // record that we had hit critical memory barrier Logger.Log( FunctionId.VirtualMemory_MemoryLow, KeyValueLogMessage.Create( m => { // which message we are logging and memory left in bytes when this is called. m["MSG"] = msg; m["MemoryLeft"] = (long)wParam; } ) ); _alreadyLogged = true; } _workspaceCacheService?.FlushCaches(); if (ShouldDisableBackgroundAnalysis((long)wParam)) { DisableBackgroundAnalysis(); ShowInfoBarIfRequired(); } // turn off low latency GC mode. // once we hit this, not hitting "Out of memory" exception is more important than typing being smooth all the time. // once it is turned off, user will hit time to time keystroke which responsive time is more than 50ms. in our own perf lab, // about 1-2% was over 50ms with this off when we first introduced this GC mode. GCManager.TurnOffLowLatencyMode(); break; } } return(VSConstants.S_OK); }