开发者

Break after certain memory limit hit

开发者 https://www.devze.com 2023-03-30 15:57 出处:网络
Is there a way to have visual studio break a c++ project if the exe reaches a certain memory limit? Say if 200mb is used by the exe, then it wil开发者_如何学编程l break and show me the line of code it

Is there a way to have visual studio break a c++ project if the exe reaches a certain memory limit? Say if 200mb is used by the exe, then it wil开发者_如何学编程l break and show me the line of code it is at.


Are you talking about the working set size or heap memory? Heap memory is easy: The debugging VC++ Runtime has _CrtSetAllocHook, which calls a user supplied function on every memory allocation/reallocation/free call.

http://msdn.microsoft.com/en-us/library/820k4tb8.aspx

You could install the hook and then sum the memory allocations. If you hit your threshold value, you can call _debugbreak() to drop into the debugger.

0

精彩评论

暂无评论...
验证码 换一张
取 消