src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs
/// <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>
Called by the Visual Studio Shell to notify components of a broadcast message.
Called by the Visual Studio Shell to notify components of a broadcast message .
public int OnBroadcastMessage(uint msg, IntPtr wParam, IntPtr lParam)
        {
            switch (msg)
            {
                case VSConstants.VSM_VIRTUALMEMORYLOW:
                case VSConstants.VSM_VIRTUALMEMORYCRITICAL:
                    {
                        if (!_alreadyLogged)
                        {
                            Logger.Log(FunctionId.VirtualMemory_MemoryLow, KeyValueLogMessage.Create(m =>
                            {
                                m["MSG"] = msg;
                                m["MemoryLeft"] = (long)wParam;
                            }));
                            _alreadyLogged = true;
                        }
                        _workspaceCacheService?.FlushCaches();
                        if (ShouldDisableBackgroundAnalysis((long)wParam))
                        {
                            DisableBackgroundAnalysis();
                            ShowInfoBarIfRequired();
                        }
                        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 ) { Logger . Log ( FunctionId . VirtualMemory_MemoryLow , KeyValueLogMessage . Create ( m => { m [ " " ] = msg ; m [ " " ] = ( long ) wParam ; } ) ) ; _alreadyLogged = true ; } _workspaceCacheService ? . FlushCaches ( ) ; if ( ShouldDisableBackgroundAnalysis ( ( long ) wParam ) ) { DisableBackgroundAnalysis ( ) ; ShowInfoBarIfRequired ( ) ; } GCManager . TurnOffLowLatencyMode ( ) ; break ; } } return VSConstants . S_OK ; }
Called by the Visual Studio Shell to notify components of a broadcast message.
Called by the Visual Studio Shell to notify components of a broadcast message .
// record that we had hit critical memory barrier // which message we are logging and memory left in bytes when this is called. // 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.
None
msg
uint
The message identifier.
The message identifier .
wParam
IntPtr
First parameter associated with the message.
First parameter associated with the message .
lParam
IntPtr
Second parameter associated with the message.
Second parameter associated with the message .