C ++:“观看"; “新",“删除"的用法经营者 [英] C++: "Watch" usage of "new", "delete" operators

查看:58
本文介绍了C ++:“观看"; “新",“删除"的用法经营者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想跟踪程序中何时分配了多少内存,并在某些情况下将其打印出来以进行调试!

I'd like to track down when and how much memory gets allocated in my program and print it out for debugging purposes under certain circumstances!

  • 每次使用new在程序中分配内存时,如何打印一条带有已分配内存量的消息?

推荐答案

调试内存问题的一种好方法是使用外部监视器,例如

An excellent way to debug memory problems is to use an external monitor such as valgrind. This will hook into the memory allocation and deallocation of your program, and print out a report at the end of your program showing any allocations that you didn't deallocate. No modification or recompilation of your program is necessary with this method.

这篇关于C ++:“观看"; “新",“删除"的用法经营者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆