.net 结果!转储堆是错误的

.net 结果!转储堆是错误的,.net,debugging,windbg,sos,.net,Debugging,Windbg,Sos,我运行命令“!dumpheap-min 62-max 64”并发现以下结果,我们发现字符串的计数是43149740,但是它们的总大小只有5146310字节,所以总大小是错误的,对吗 Statistics: MT Count TotalSize Class Name 00007fff0faaf518 1 100 System.Runtime.Serialization.Formatters.Binary.InternalPri

我运行命令“!dumpheap-min 62-max 64”并发现以下结果,我们发现字符串的计数是43149740,但是它们的总大小只有5146310字节,所以总大小是错误的,对吗

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字节的数据)的字符串


它是从prod env生成的,因此无法重新编程。您是否可以尝试答案中的代码?是的,样本的测试与您在我的环境中的测试相同,似乎问题发生在特殊情况下,顺便说一句,转储的大小为7G。
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;
        }
    }
}
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