diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs index ed6f345035faa083e4d79cac427724963377ef4f..2079e7ebaf6a360cb72233e3221b2bc5a8e01fbb 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs @@ -100,7 +100,12 @@ protected static ValueSource CreateRecoverableText(TextAndVersio { var result = new RecoverableTextAndVersion(CreateStrongText(text), services.TemporaryStorage); - // Ensure the recoverable text is saved in temporary storage + // This RecoverableTextAndVersion is created directly from a TextAndVersion instance. In its initial state, + // the RecoverableTextAndVersion keeps a strong reference to the initial TextAndVersion, and only + // transitions to a weak reference backed by temporary storage after the first time GetValue (or + // GetValueAsync) is called. Since we know we are creating a RecoverableTextAndVersion for the purpose of + // avoiding problematic address space overhead, we call GetValue immediately to force the object to weakly + // hold its data from the start. result.GetValue(); return result;