寻找记忆的地方上次释放?

问题描述:

很一般:​​
有没有一种简单的方法来判断何时访问冲突发生时code线最后释放的内存块?

Very general: Is there an easy way to tell which line of code last freed a block of memory when an access violation occurs?

减一般:
我剖析的理解是,他们覆盖的分配和释放的过程。如果这是真的,他们可能会发生存储code的,去年释放的内存部分,这样,当后来因为崩溃的访问冲突的,你知道是什么释放,那么它最后行了?

Less general: My understanding of profilers is that they override the allocation and deallocation processes. If this is true, might they happen to store the line of code that last freed a section of memory so that when it later crashes because of an access violation, you know what freed it last?

具体细节:
Windows中,ANSI C,使用Visual Studio

Specifics: Windows, ANSI C, using Visual Studio

是的!

安装的Windows调试工具,并使用应用程序验证。


  1. 文件 - >添加应用程序,选择您的.exe

  2. 在基础知识,选择记忆和堆。

  3. 在NTSD(NTSD yourprogram.exe)运行程序的调试版本。

  4. 重现错误。

现在当你崩溃发生,你会得到从AppVerifier的调试器附加信息。使用!avrf(可能需要很长的时间来运行(分钟)),它会尝试给你尽可能多的有用信息。

Now when you make the crash happen, you will get additional information in the debugger from AppVerifier. Use !avrf (may take a long time to run (minutes)) and it will try to give you as much useful information as possible.

您都可以​​使用的内存地址的dps命令来获取所有存储堆栈信息(分配,释放,等​​等)。

You can all use the dps command on the memory address to get all the stored stack info (allocation, deallocation, etc).

您还可以在内存地址使用堆命令:!

You can also use the !heap command on the memory address:

0:004> !heap -p -a 0x0C46CFE0

这将转储信息,以及。

Which will dump information as well.

延伸阅读:

  • Advanced Windows Debugging, Hewardt and Pravat
  • Debugging with PageHeap