提交 bfa9bbcd 编写于 作者: W Wonseok Chae

Merge pull request #1483 from wschae/memory

Do not allocate too much for Guid stream
......@@ -5946,5 +5946,36 @@ public class C
CheckNames(new[] { reader0, reader1 }, reader1.GetTypeDefNames(), "<>o__0#1");
CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetTypeDefNames(), "<>o__0#2");
}
[WorkItem(918650)]
[Fact]
public void OutofMemoryDuringEditAndContinue()
{
var source =
@"class C
{{
static int F() {{ return {0}; }}
}}";
var compilation0 = CreateCompilationWithMscorlib(String.Format(source, 1), options: TestOptions.DebugDll);
var bytes0 = compilation0.EmitToArray();
var md0 = ModuleMetadata.CreateFromImage(bytes0);
var generation0 = EmitBaseline.CreateInitialBaseline(md0, EmptyLocalsProvider);
var method0 = compilation0.GetMember<MethodSymbol>("C.F");
for (int i = 2; i <= 50; i++)
{
var compilation1 = compilation0.WithSource(String.Format(source, i));
var method1 = compilation1.GetMember<MethodSymbol>("C.F");
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(new SemanticEdit(SemanticEditKind.Update, method0, method1)));
compilation0 = compilation1;
method0 = method1;
generation0 = diff1.NextGeneration;
}
}
}
}
......@@ -166,8 +166,8 @@ internal EmitBaseline GetDelta(EmitBaseline baseline, Compilation compilation, G
stringStreamLengthAdded: metadataSizes.HeapSizes[(int)HeapIndex.String] + _previousGeneration.StringStreamLengthAdded,
// UserString stream is concatenated aligned.
userStringStreamLengthAdded: metadataSizes.GetAlignedHeapSize(HeapIndex.UserString) + _previousGeneration.UserStringStreamLengthAdded,
// Guid stream is always aligned (the size if a multiple of 16 = sizeof(Guid))
guidStreamLengthAdded: metadataSizes.HeapSizes[(int)HeapIndex.Guid] + _previousGeneration.GuidStreamLengthAdded,
// Guid stream accumulates on the GUID heap unlike other heaps, so the previous generations are already included.
guidStreamLengthAdded: metadataSizes.HeapSizes[(int)HeapIndex.Guid],
anonymousTypeMap: ((IPEDeltaAssemblyBuilder)moduleBuilder).GetAnonymousTypeMap(),
synthesizedMembers: synthesizedMembers,
addedOrChangedMethods: AddRange(addedOrChangedMethodsByIndex, _previousGeneration.AddedOrChangedMethods, replace: true),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册