Log Format
The log files are in XML format. The following is an explanation of the fields in the log file:
The LEAKS element displays the version of leakdiag that the log was generated with. This would match the version of inject.dll.
<LEAKS ver="1.25.28.2002">
The STACK element contains the data for each stack that has allocated memory, and that memory has not yet been freed. In other words, a STACK will only be in the log file if it has allocated some memory, and that memory is still in use. This does not mean that every STACK is a leak, only that it has allocated memory, and that memory is not freed yet.
The STACK structure contains a statistics section, and then a call stack section. The attributes of the STACK element are numallocs, size, and totalsize. The numallocs attribute refers to the number of allocations that this stack currently has outstanding. In our example stack, that means that there are 19000 allocations that have not been freed yet. The size attribute is an average size of each allocation. It is derived by dividing totalsize by numallocs. Specific allocation sizes are listed in the STACKSTATS section. The totalsize attribute refers to the total amount of bytes this stack has outstanding. In our example that amount is 19MB. So, in the STACK bellow, there were 19000 allocations totaling 19MB that have not yet been freed.
The STACKSTATS section conatins a breakdown of the sizes and heaps that the allocations were made out of. The SIZESTAT element shows an explicit size and the number of times that size was allocatied by this stack. The HEAPSTAT section shows an explicit heap handle, and the number of allocations from that heap by this stack. So, in the example bellow, this stack only allocated one distinct size, of 1024 bytes, 19000 times, and all 19000 of those allocations came from the heap with the handle 7d0000.
The FRAME elements make up the call stack back trace. This is the list of return addresses that made the allocations. The FRAME element has a num, dll, function, offset, filename, line, and addr attributes. The num attribute is simply a FRAME number. It is 0 based. The dll attribute is module name, in this case MemTester.exe. The function attribute is name of the function, if that was available at the time the log was generated. This name is derived from symbols, either in the module itself, or in a symbol file. See the Using Symbols topic for more information. The offset attribute is the number of bytes into the function from the start address. This is also derived from symbolic information and is only as accurate as that information. The filename attribute is the source code for the function, if that information is available. This is also from symbolic information. The line attribute is the line number in the source code. The addr attribute is the explict return address of the function.
The STACKID element is a unique identifier for each stack. It can used to compare multiple logs from the same instance of an application to observe trends.
<STACK numallocs="019000" size="01024" totalsize="019456000">
<STACKSTATS>
<SIZESTAT size="01024" numallocs="019000"/>
<HEAPSTAT handle="7d0000" numallocs="019000"/>
</STACKSTATS>
<FRAME num="0" dll="MemTester.exe" function ="DLG_RtlAllocateHeapProc" offset="0xC4" filename="c:\code\memtester\memtester.cpp" line="331" addr="0x4011B4" />
<STACKID>00944660</STACKID>
</STACK>
//下载地址: http://pan.baidu.com/s/1boZOD1l
本文深入解读XML格式的日志文件结构,详细介绍日志中包含的元素及其作用,着重解释如何通过分析STACK元素来追踪内存泄漏,包括分配次数、大小、总大小等关键信息,并通过FRAME元素追溯到具体的堆栈调用路径。
385

被折叠的 条评论
为什么被折叠?



