[转]Windows上的valgrinddeleaker

摘要:
ValgrindisadevelopertoolforC++developersusedtofindmemoryissuesincludingC++memoryleakdetection.Valgrindusesinstrumentationtocollectinformationaboutallocatedandfreedmemorytogathercompleteinformationabou

Valgrindis a developer tool for C++ developers used to find memory issues including C++ memory leak detection. Valgrind uses instrumentation to collect information about allocated and freed memory to gather complete information about memory blocks.

Many developers ask how to use Valgrind on Windows and Visual Studio. Valgrind heavy relies on Linux internals, that’s why Valgrind does not support Windows.

Fortunately, there is a Valgrind alternative for Windows, called Deleaker. It is a memory profiler tool for Windows. While Valgrind uses instrumentation that makes the code slower about 10x times, Deleaker uses hooks and does not modify code of a program: code execution speed remains almost the same. Deleaker doesn’t require a program to be rebuilt. All what Deleaker needs is a debug information to locate source of leaks.

Also Deleaker detects Windows specific leaks such as GDI leaks, leaks of handles.

Deleaker can work as a standalone application and as an extension for Visual Studio. The standalone version is suitable for memory leaks profiling on a client machine when the installation of Visual Studio is not allowed. If your favourite IDE is Qt Creator or C++ Builder, it is worth mentioning that Deleaker integrates with them as well.

With Deleaker extension for Visual Studio, a developer checks code for memory leaks, identifying exact leaking places quite quickly. Deleaker assists a developer, showing list of allocated memory blocks with their call stacks and other information including hit count, size, module path and others.

Let’s look at how it works. Create new console application and add a simple leak:

1
2
3
4
5
6
7
8
9
10
11
12
<br>
#include <windows.h></windows.h></p>
<p>intmain()<br>
{<br>
for(inti = 0; true; i++)<br>
{<br>
newint[100000];<br>
CreateEventW(NULL, FALSE, FALSE, NULL);<br>
CreateDC(L"DISPLAY", NULL, NULL, NULL);<br>
Sleep(500);<br>
}<br>
}<br>

Before starting debugging, ensure that Deleaker is enabled:

[转]Windows上的valgrinddeleaker第1张

Start debugging. The application allocates memory and exits. Once the debugging stopped, Deleaker takes a snapshot and shows a report. To navigate to the source of a leak, just right-click and select Show Source Code:

[转]Windows上的valgrinddeleaker第2张

Deleaker can compare snapshots to find some recurring leaks. Also a developer can export snapshots to review them later.

Deleaker comes with a command line tool, DeleakerConsole.exe, that can be used to integrate memory leaks checking into continuous integration process to ensure that an application does not leak. DeleakerConsole.exe prepares memory leaks reports in XML format that can be analyzed.

If you are looking for an alternative of Valgrind, try Deleaker. It is a C++ memory leak detection tool for Windows that is fast, supports both 32-bit and 64-bit code, and integrates with all major IDE including Visual Studio, Qt Creator and RAD Studio.

Valgrind for Windows – Deleaker Blog

免责声明:文章转载自《[转]Windows上的valgrinddeleaker》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇【指导】SonarQube 部署说明linq之into子句下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

solidity中的memory和 storage详解

Solidity是一种智能合约高级语言,运行在Ethereum虚拟机(EVM)之上。这里我会讲解一下关键字storage和memory的区别。 storage的结构是在合约部署创建时,根据你的合约中状态变量的声明,就固定下来了,并且不能在将来的合约方法调用中改变这个结构。但是,storage中的内容是可以通过交易来改变的。这些交易调用因此将修改合约的状态。...

channel 介绍

!!!1.Memory Channel 内存通道 事件将被存储在内存中的具有指定大小的队列中。 非常适合那些需要高吞吐量但是失败是会丢失数据的场景下。   属性说明: !type – 类型,必须是“memory” capacity 100 事件存储在信道中的最大数量 transactionCapacity 100 每个事务中的最大事...

配置大页内存实施方案

一、概述HugePages是通过使用大页内存来取代传统的4kb内存页面,使得管理虚拟地址数变少,加快了从虚拟地址到物理地址的映射以及通过摒弃内存页面的换入换出以提高内存的整体性能。尤其是对于8GB以上的内存以及较大的Oracle SGA size,建议配值并使用HugePage特性。同时, hugepage是作为一个优化项,而不是必须设置项。如果系统性能稳...

深入理解kubernetes(K8s)的Qos, requests和limits

Kubernetes的服务质量保证(QoS) Kubernetes需要整体统筹平台资源使用情况、公平合理的将资源分配给相关pod容器使用,并且要保证容器生命周期内有足够的资源来保证其运行。 与此同时,由于资源发放的独占性,即资源已经分配给了某容器,同样的资源不会在分配给其他容器,对于资源利用率相对较低的容器来说,占用资源却没有实际使用(比如CPU、内存)造...

V4L2驱动的移植与应用(二)

二、V4L2的应用 下面简单介绍一下V4L2驱动的应用流程。 1、 视频采集的基本流程 一般的,视频采集都有如下流程: 2、 打开视频设备 在V4L2中,视频设备被看做一个文件。使用open函数打开这个设备: // 用非阻塞模式打开摄像头设备int cameraFd;cameraFd = open("/dev/video0", O_RDWR | O_NO...

关于redis性能问题分析和优化

一、如何查看Redis性能 info命令输出的数据可以分为10个分类,分别是: server,clients,memory,persistence,stats,replication,cpu,commandstats,cluster,keyspace 为了快速定位并解决性能问题,这里选择5个关键性的数据指标,它包含了大多数人在使用Redis上会经常碰到的性...