当堆 > 时条件断点一些限制

发布于 2024-10-02 16:29:44 字数 84 浏览 0 评论 0原文

当附加进程的分配内存大于某个值时,是否可以中断调试器?

最好使用 Visual Studio 2005,但也可以选择其他 IDE/调试器。

Is it possible to break into debugger when the allocated memory of attached-to process becomes bigger than a certain value?

Preferrably using Visual Studio 2005, but other IDE's/debuggers are an option.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

忘羡 2024-10-09 16:29:44

没有直接的方法可以做到这一点。另一种方法是在 CRT 分配代码中的某处设置普通断点,并在命中计数是 2000 的倍数时将其设置为中断。您将足够快地进入所需状态。

There is no direct way to do it. Alternative is to set ordinary breakpoint somewhere inside CRT allocation code, and set it to break when the hit count is multiple of say 2000. You'll get to wanted state quickly enough.

她比我温柔 2024-10-09 16:29:44

我不知道 Visual Studio 中有任何直接的方法,但您可以使用 ProcDump< /a> 当内存提交阈值达到特定值时创建故障转储(-m 选项)。

然后,您需要使用 WinDbg(Windows 调试工具)来检查堆。

I don't know of any direct way in Visual Studio, but you could use ProcDump to create a crash dump when the Memory commit threshold reaches a certain value (-m option).

You would then need to use WinDbg (part of the Windows debugging tools) to inspect the heap.

懵少女 2024-10-09 16:29:44

这个问题可能很旧,但仍然相关。

您可以使用以下函数检查可用内存:

https ://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex

https://learn.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getprocessmemoryinfo

然后,偶尔从主线程调用该函数,或者运行一个单独的线程来监视主线程。您可以在监视代码中设置断点,以便在内存使用超过定义的阈值时中断执行。

The question may be old, but it is still relevant.

You can check available memory using these functions:

https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex

https://learn.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getprocessmemoryinfo

Then, either call that function from your main thread occasionally or run a separate thread to monitor the main thread. You can have a breakpoint in the monitoring code to break execution if memory use exceeds a defined threshold.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文