- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在WinDbg命令中运行转储文件
地址-摘要
我的结果是这样的
Usage Summary RgnCount Total Size %ofBusy %ofTota
Free 3739 7ff5`dbbae000 ( 127.960 Tb) 99.97%
<unknown> 1677 5`680a1000 ( 21.626 Gb) 53.31% 0.02%
Heap 20349 4`0049f000 ( 16.005 Gb) 39.45% 0.01%
Stack 230 0`a3e90000 ( 2.561 Gb) 6.31% 0.00%
class Program
{
public static int[] arr;
public static AllocateUnmanagedMemory cls;
static void Main(string[] args)
{
const int GBSize = 1 * 1024 * 1024 * 1024/ sizeof(int);
Console.WriteLine("Allocating");
arr = new int[GBSize];
cls = new AllocateUnmanagedMemory();
cls.UnmanagedAllocation();
Console.ReadLine();
}
}
static IntPtr pointer;
public void UnmanagedAllocation()
{
pointer = Marshal.AllocHGlobal(1024 * 1024 * 1024 );
}
-- Usage Summary RgnCount ----------- Total Size -------- %ofBusy %ofTotal
Free 59 762f7000 ( 1.847 GB) 46.17%
<unknown> 98 4493e000 ( 1.072 GB) 49.76% 26.79%
Heap 15 40158000 ( 1.001 GB) 46.50% 25.03%
Image 174 2db2000 ( 45.695 MB) 2.07% 1.12%
MappedFile 15 1c51000 ( 28.316 MB) 1.28% 0.69%
Stack 24 800000 ( 8.000 MB) 0.36% 0.20%
最佳答案
基础
命令!address
在非常低的级别上运行,仅在操作系统之上。但是,它将识别Windows附带的一点内存管理器:Windows Heap Manager。
因此,您看到的Heap
是通过Windows Heap管理器分配的内存。从您的理解水平来看,这就是本机堆。
任何其他堆管理器都将实现自己的内存管理。基本上,它们的工作原理都相似:它们从VirtualAlloc()
获取大块内存,然后尝试对该大块中的小块进行更好的映射。由于WinDbg不知道这些内存管理器中的任何一个,因此将该内存声明为<unknown>
。它包括但不限于.NET的托管堆。有关其他潜在用途,请参见this answer。Free
是可以从操作系统中潜在使用的内存。这可能包括交换空间,而不仅仅是物理RAM。Stack
,我想这很明显。
堆
如何在堆中找到内容?什么是对象或什么是类型?
这个问题的答案在很大程度上取决于您在谈论哪个堆。
Windows堆管理器(“本机堆”)仅管理内存,不管理类型。在该级别上,无法区分大小相同但类型不同的两个对象。如果发生内存泄漏,则只能给出类似“我有n个字节的泄漏”的语句。要查找有关本机堆的更多信息,请从!heap -s
开始并查找其他!heap
命令。
.NET托管堆保留类型系统。要分析托管堆,您需要WinDbg的扩展名为sos。通常,您通过.loadby sos clr
加载它。它具有命令!dumpheap -stat
,可能会给您第一印象。 (如果收到错误消息,请运行两次命令)
这应该给您足够的提示,以便进行进一步的研究并在崩溃转储中找到更多详细信息。
奇怪?
您似乎有230个堆栈,总共有2.5 GB的内存。每个堆栈大约有11 MB的内存。通常限制为1 MB。
您更新的示例代码
我编译了以下程序
using System;
using System.Runtime.InteropServices;
namespace SO55043889
{
class Program
{
public static int[] arr;
static IntPtr pointer;
static void Main()
{
const int GBSize = 1 * 1024 * 1024 * 1024/ sizeof(int);
Console.WriteLine("Allocating");
arr = new int[GBSize];
pointer = Marshal.AllocHGlobal(1024 * 1024 * 1024 );
Console.ReadLine();
Console.WriteLine(pointer.ToInt32() + arr[0]);
}
}
}
0:000> .dump /ma SO55043889.dmp
0:000> !address -summary
[...]
<unknown> 106 474f4000 ( 1.114 GB) 51.58% 27.86%
Heap 13 401e1000 ( 1.002 GB) 46.38% 25.05%
[...]
0:000> .loadby sos clr
0:000> !dumpheap -stat
c0000005 Exception in C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dumpheap debugger extension.
PC: 04f6fa73 VA: 00000000 R/W: 0 Parameter: 00000000
0:000> *** This is normal, just do it again
0:000> !dumpheap -stat
[...]
70d20958 12 1073742400 System.Int32[]
Total 335 objects
0:000> !dumpheap -type System.Int32[]
Address MT Size
020e1ff8 70d20958 300
020e2130 70d20958 24
020e2184 70d20958 40
020e2228 70d20958 80
020e2d9c 70d20958 16
020e2dac 70d20958 16
020e2df8 70d20958 16
020e386c 70d20958 24
020e3d54 70d20958 16
020e3d64 70d20958 16
020e3d74 70d20958 16
04811010 70d20958 1073741836
Statistics:
MT Count TotalSize Class Name
70d20958 12 1073742400 System.Int32[]
Total 12 objects
0:004> !heap -s
LFH Key : 0x7f8d0cc6
Termination on corruption : ENABLED
Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast
(k) (k) (k) (k) length blocks cont. heap
-----------------------------------------------------------------------------
Virtual block: 80010000 - 80010000 (size 00000000)
00550000 00000002 1024 504 1024 14 17 1 1 0 LFH
002d0000 00001002 64 16 64 2 2 1 0 0
00820000 00041002 256 4 256 2 1 1 0 0
00750000 00001002 64 20 64 7 2 1 0 0
00710000 00001002 256 4 256 0 1 1 0 0
001e0000 00041002 256 4 256 2 1 1 0 0
-----------------------------------------------------------------------------
VirtualAlloc()
中的大块(64kB)分成较小的块。之所以这样做,是因为仅为4个字节的
int
分配64kB会是一大浪费。但是,无需为大型块创建堆管理结构。对于2 ^ 30 + 1字节的分配,操作系统将返回2 ^ 30 + 64kB,这意味着开销仅为0.006%。
Virtual block
中的原因,这意味着Windows Heap Manager只是将请求转发到了
VirtualAlloc()
。
size
的输出已损坏。它说
(size 00000000)
0:004> !address 80010000
Usage: Heap
Base Address: 80010000
End Address: c0011000
Region Size: 40001000
[...]
0:004> ? c0011000-80010000
Evaluate expression: 1073745920 = 40001000
End Adress
-
Base Address
等于
Region Size
,大小为1 GB。
VirtualAlloc()
。您不会弄清楚是谁分配了1 GB的块。
0:000> !gflag
Current NtGlobalFlag contents: 0x00001000
ust - Create user mode stack trace database
0:000> !heap -flt s 208
_HEAP @ 2a0000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
002c9818 0044 0000 [00] 002c9830 00208 - (busy)
002cd1e8 0044 0044 [00] 002cd200 00208 - (busy)
002d5ad0 0044 0044 [00] 002d5ae8 00208 - (busy)
002f0c48 0044 0044 [00] 002f0c60 00208 - (busy)
0032c210 0044 0044 [00] 0032c228 00208 - (busy)
00351c90 0044 0044 [00] 00351ca8 00208 - (busy)
0:000> *** Use any UserPtr number, I use the last one
0:000> !heap -p -a 00351ca8
address 00351ca8 found in
_HEAP @ 2a0000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
00351c90 0044 0000 [00] 00351ca8 00208 - (busy)
779dd909 ntdll!RtlAllocateHeap+0x00000274
71e18bc7 clr!EEHeapAlloc+0x0000002c
71e18c0a clr!EEHeapAllocInProcessHeap+0x0000005b
71e18ba6 clr!ClrAllocInProcessHeap+0x00000023
71e2dd26 clr!StackingAllocator::AllocNewBlockForBytes+0x00000082
71e2dd76 clr!operator new+0x00000063
71e93ace clr!MethodTableBuilder::BuildMethodTableThrowing+0x00000059
71e94590 clr!ClassLoader::CreateTypeHandleForTypeDefThrowing+0x0000083a
71e2e956 clr!ClassLoader::CreateTypeHandleForTypeKey+0x000000ad
71e2e99a clr!ClassLoader::DoIncrementalLoad+0x000000c2
71e2e418 clr!ClassLoader::LoadTypeHandleForTypeKey_Body+0x00000505
71e2e5a7 clr!ClassLoader::LoadTypeHandleForTypeKey+0x000000b5
71e2f723 clr!ClassLoader::LoadTypeDefThrowing+0x00000318
71e2a974 clr!ClassLoader::LoadTypeDefOrRefThrowing+0x0000024c
71f57811 clr!Assembly::GetEntryPoint+0x0000022f
71f856e0 clr!Assembly::ExecuteMainMethod+0x000000b3
71f855ed clr!SystemDomain::ExecuteMainMethod+0x00000631
71f858d3 clr!ExecuteEXE+0x0000004c
71f85819 clr!_CorExeMainInternal+0x000000dc
71f55a0c clr!_CorExeMain+0x0000004d
7251d93b mscoreei!_CorExeMain+0x0000010e
72597f16 MSCOREE!ShellShim__CorExeMain+0x00000099
72594de3 MSCOREE!_CorExeMain_Exported+0x00000008
77999802 ntdll!__RtlUserThreadStart+0x00000070
779997d5 ntdll!_RtlUserThreadStart+0x0000001b
for (int i = 0; i < 1000; i++)
{
pointer = Marshal.AllocHGlobal(3*1024 );
}
0:004> ? 3*0n1024
Evaluate expression: 3072 = 00000c00
0:004> !heap -flt c00
cound not parse flt criteria -flt c00
0:004> !heap -flt s c00
_HEAP @ 67c0000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
0686b668 0183 0000 [00] 0686b680 00c00 - (busy)
0686efa8 0183 0183 [00] 0686efc0 00c00 - (busy)
[...]
0:004> !heap -p -a 4d0fdf18
address 4d0fdf18 found in
_HEAP @ 67c0000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
4d0fdf00 0191 0000 [00] 4d0fdf18 00c00 - (busy)
779dd909 ntdll!RtlAllocateHeap+0x00000274
768f5aae KERNELBASE!LocalAlloc+0x0000005f
70c6ad4f mscorlib_ni+0x003fad4f
7138c4da mscorlib_ni+0x00b1c4da
71e0ebb6 clr!CallDescrWorkerInternal+0x00000034
71e11e10 clr!CallDescrWorkerWithHandler+0x0000006b
71e17994 clr!MethodDescCallSite::CallTargetWorker+0x0000016a
71f85026 clr!RunMain+0x000001ad
71f85707 clr!Assembly::ExecuteMainMethod+0x00000124
[...]
k
或
!dumpstack
在.NET中具有不同堆栈的相同原因。
关于heap - 如何通过WinDBG在Dump中查找非托管内存中的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55043889/
我正在为我的按钮使用 onClick 功能。我的按钮代码如下所示: Button 1 Button 2 我的 JS 函数如下所示: function fadeNext(selectedId, spee
首先,我想提一下,我理解每个人在不提供至少一些试验或错误的情况下提出问题的感受,但这纯粹是一种知识需求,话虽如此,我会去提前问。 我一直无法弄清楚如何将保存在 MySQL 表中的 600-1000 个
我想做的事情有点令人困惑,而且我英语不太好,所以我先把代码贴在这里,这样你就可以很容易地理解: 以下是表单内容: Testing for Stackoverflow Option1
我学习 SDL 二维编程已有一段时间了,现在我想创建一个结合使用 SDL 和 OpenGL 的程序。我是这样设置的: SDL_Init(SDL_INIT_VIDEO); window = SDL_Cr
我创建了 2 个 data-* 标签。数据类别和数据标签。单击 href 标签后,我想复制该数据类别和数据标签以形成输入。我的代码是:
我想用 CSS 换行。我正在使用内容。 td:before { content: "Test\A Test2"; } 它不工作。如何正确
这个问题已经有答案了: Java Class that implements Map and keeps insertion order? (8 个回答) 已关闭 6 年前。 我有一个 HashMap
我正在尝试使用 JMeter 执行端到端测试。测试涉及写入SFTP文件夹并从另一个SFTP文件夹读取写入操作生成的文件。 我能够使用 JMeter SSH SFTP 插件连接到 SFTP 文件夹,并能
您好,我有带有标准服务器端 Servlet 的 GWT 客户端。 我可以从 GWT 客户端上传文件并在服务器端读取其内容 我可以将其作为字符串发送回客户端 但是 我有 GWT FormPanel与操作
我在 Plone 4.3.9 中创建了一个自定义类型的灵巧性,称为 PersonalPage,必须只允许在特定文件夹中使用 成员文件夹/用户文件夹 . 在他的 FTI 中,默认情况下 False .
在新(更新)版本的应用程序中更改小部件布局的最佳做法是什么?当新版本提供更新、更好的小部件时,如何处理现有小部件? 最佳答案 我认为您必须向用户显示一个弹出窗口,说明“此版本中的新功能”并要求他们重新
在我的应用程序中,我使用支持 View 寻呼机和 PagerTabStrip。进入查看寻呼机我有一些 fragment ,进入其中一个我正在使用支持卡片 View 。运行应用程序后,所有卡片 View
我有以下布局文件。基本上我有谷歌地图,在左上角我有一个 TextView,我需要在其中每 15 秒保持一次计数器以刷新 map 。布局很好。
我使用如下结构: HashMap > > OverallMap 如果我这样做: OverallMap . clear ( ) clear() 丢弃的所有内容(HashMap 对象、Integer 对
我在数据库中有 1000 张图像。在页面加载时,我随机显示 60 张图片,当用户滚动时,我通过 AJAX 请求添加 20 张图片。 第一种方法 我所做的是将所有图像加载到一个容器中,然后隐藏所有图像并
我正在使用 woocommerce 创建一个网上商店。 我想在每个产品上添加一个包含产品信息的表格,例如颜色、交货时间等等。 但是当我添加这张表时。本产品消失后的所有内容。 我的表的代码: td {
This question already has an answer here: What does an empty value for the CSS property content do?
因此,我正在与我的 friend 一起为 Google Chrome 开发一个扩展程序,对于大多数功能(即日历、设置等),我们打开一个模式,这样我们就不必重定向到另一个页面。当您在内容之外单击时,我们
我将可变高度的 CSS 框设置为在更大的 div 中向左浮动。现在我想添加一个标题,其中文本在框的左侧垂直显示(旋转 90 度),如下面的链接所示(抱歉还不能发布图片)。 http://imagesh
相关页面位于 www.codykrauskopf.com/circus 如果您查看我页面的右侧,在半透明容器和浏览器窗口边缘之间有一个间隙。我看了看,出于某种原因,wrap、main、content
我是一名优秀的程序员,十分优秀!