コマンド「!dumpheap-min 62 -max 64」を実行すると、次の結果が見つかりました。文字列の数は43,149,740ですが、合計サイズは5,146,310バイトなので、合計サイズが間違っていますね。
Statistics:
MT Count TotalSize Class Name
00007fff0faaf518 1 100 System.Runtime.Serialization.Formatters.Binary.InternalPrimitiveTypeE[]
00007fff0fb22c98 2 200 System.Int16[]
00007fff0fb06888 36 3532 System.Byte[]
00007fff0fb02090 174 17124 System.Char[]
00007fff0fb03920 545 54500 System.Int32[]
00007fff0fb00e08 **43149740** **5146310** System.String
Total 43150498 objects
質問で提供された情報は、問題の原因を明確に伝えるのに十分ではない可能性があります。これは、再現できないバージョン固有の問題であるか、ヒープが壊れている(実行!verifyheap
)可能性があります。
次のプログラムは、長さ64(128バイトのデータ)、長さ200(400バイトのデータ)、および長さ1024(2048バイトのデータ)の文字列を作成します。
using System;
using System.Collections.Generic;
namespace StringSizeDumpheap
{
class Program
{
static void Main(string[] args)
{
List<string> smallstrings = CreateList(1000, 64);
List<string> mediumstrings = CreateList(1000, 200);
List<string> largestrings = CreateList(1000, 1024);
const string dbginfo = "Debug now. Use !dumpheap -min -max with 0n140/0n144, 0n400/0n440 and 0n2000/0n2200.";
Console.WriteLine(dbginfo);
Console.ReadLine();
// Access strings to prevent optimization
smallstrings[0] = "";
mediumstrings[0] = "";
largestrings[0] = "";
}
private static List<string> CreateList(int count, int size)
{
List<string> list = new List<string>();
for (int i = 0; i < count; i++)
{
list.Add(new string('x', size));
}
return list;
}
}
}
そのデモプログラムを使用すると、WinDbg + SOSはWinDbg6.2.9200で期待される結果をもたらします(.NET 4.5.2としてコンパイルされたプログラム、32ビット優先、デバッグビルド)
0:004> !dumpheap -stat -mt 70dde918 -min 0n140 -max 0n144
Statistics:
MT Count TotalSize Class Name
70dde918 1002 142284 System.String
Total 1002 objects
0:004> !dumpheap -stat -mt 70dde918 -min 0n380 -max 0n500
Statistics:
MT Count TotalSize Class Name
70dde918 1000 414000 System.String
Total 1000 objects
0:004> !dumpheap -stat -mt 70dde918 -min 0n2000 -max 0n2200
Statistics:
MT Count TotalSize Class Name
70dde918 1000 2062000 System.String
Total 1000 objects
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加