相关疑难解决方法(0)

Mac OS:泄漏消毒剂

Mac OS X 塞拉利昂 10.13

我按照这里写的 https://clang.llvm.org/docs/LeakSanitizer.html

即创建了内存泄漏的小应用程序

#include <stdlib.h>
void *p;
int main() {
  p = malloc(7);
  p = 0; // The memory is leaked here.
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

然后构建并运行以测试如何检测内存泄漏:

admins-Mac:test2 admin$ clang -fsanitize=address -g mleak.c ; ASAN_OPTIONS=detect_leaks=1 ./a.out
==556==AddressSanitizer: detect_leaks is not supported on this platform.
Abort trap: 6
admins-Mac:test2 admin$ 
Run Code Online (Sandbox Code Playgroud)

我如何检测泄漏?我需要将它用于我的大型应用程序。

macos memory-leaks address-sanitizer

8
推荐指数
2
解决办法
5046
查看次数

标签 统计

address-sanitizer ×1

macos ×1

memory-leaks ×1