- 博客(6)
- 收藏
- 关注
原创 C++ std::weak_ptr的使用
在C++中,std::weak_ptr是一种智能指针,用于避免循环引用问题,尤其是在使用std::shared_ptr时。当两个对象相互引用时,如果使用std::shared_ptr,会导致循环引用,资源无法释放。std::weak_ptr是一种弱引用,不会增加对象的引用计数,因此可以打破循环引用。以下是一个简单的示例,演示如何使用std::weak_ptr来解决循环引用问题。
2024-05-18 22:01:00
744
原创 VS2019检测内存泄漏
Finding memory leaks in a C++ application with Visual Studio1、Put a breakpoint on the first line “int a…”2、Click Debug > Windows > Show Diagnostic Tools; and pick memory usage3、Then debug the code (F5), when the breakpoint is hit, click Take snapshot on
2023-11-28 21:02:29
1948
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人