我似乎无法将MS泄漏检测器用于新表达式“new(std::nothrow)”.是这样吗
It seems like I cannot use MS leak detector for the new expression `new (std::nothrow)`. Is that correct?
我正在尝试使用新表达式new (std::nothrow)
获取发生泄漏的文件和行。
下面代码中有注释的新表达式未编译。
#include <iostream>
int main()
{
#ifdef _DEBUG
int* p = new (_NORMAL_BLOCK, __FILE__, __LINE__) int(10);
// int* q = new (std::nothrow, _NORMAL_BLOCK, __FILE__, __LINE__) int(10);
#else
int* p = new int(10);
int* q = new int(10);
#endif
_CrtDumpMemoryLeaks();
}
我也很想知道<iostream>
在哪里包括<crtdbg.h>
。我就是找不到它。但当然,它一定在那里,在某个地方。
不直接。微软不提供void* operator new(std::nothrow_t, const char* file, int line)
,但你可以自己提供。只需转发到抛出版本和catch
处理程序return NULL;
中。
相关文章:
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- 为什么 std::make_shared 无法编译带有已删除运算符 new 的类型?
- 为什么 std::vector 使用 std::分配器而不是运算符 new 和 delete?
- new(std::nothrow) int[n] 抛出异常
- C++ std::字符串语法 "new (&y) std::string(x);"
- std :: vector new的记忆不足
- Linux g++ new (std::nothrow) 确实有效
- 访问std :: MAP中的静态构造函数New New拨号
- C++ std::vector<> vs new[] 性能
- 使用 "new ClassType(std::move(/*class_object*/))" 在自由存储中构造对象
- new(std::nothrow)而不是new和错误处理
- 如何使用new(std::nothrow)使构造函数失败
- std::shared_ptr 初始化:make_shared<Foo>() vs shared_ptr<T>(new Foo)
- new int[size] vs std::vector
- 我似乎无法将MS泄漏检测器用于新表达式“new(std::nothrow)”.是这样吗
- 为具有已替换运算符new的类自定义std::分配器
- 为什么C++不需要"new"语句来初始化 std::vector?
- 在标准中哪里说' new '返回的每个分配都对齐到' std::max_align_t '
- 如何生成和使用c++11中的std::数组,使用new来使用堆而不是堆栈
- std::make_shared(new Foo())是否创建单例?