macOS Mojave 10.14.2的Valgrind?有其他选择吗?

问题描述 投票:5回答:1

[好,所以我看到四个月前有人问这个问题。但是自莫哈韦沙漠爆发以来,这已经是一个不错的时机。有谁知道如何使它工作或可能有其他选择,以便我可以检查程序是否存在内存泄漏。我是一名学生,因此费用确实很重要,但这是我的几门课的要求。考虑到它们在Mac上无法正常运行,我宁愿不必使用虚拟机。任何建议都很好。谢谢。

valgrind macos-mojave
1个回答
0
投票

您在这里没有什么选择。

  1. 您可以使用XCode进行开发,并以Profile模式运行代码。

  2. 您可以启动Instruments并附加到进程

  3. 您可以运行代码并使用leaks确定泄漏大小

> leaks 2419
Process:         LeakingTheMemory [2419]
Path:            /Users/USER/*/LeakingTheMemory
...
...
...
leaks Report Version: 4.0
Process 2419: 196 nodes malloced for 262162 KB
Process 2419: 26 leaks for 134217760 total leaked bytes.

    26 (128M) << TOTAL >>
      1 (64.0M) ROOT LEAK: 0x10b17c000 [67108864]
      1 (32.0M) ROOT LEAK: 0x105726000 [33554432]
      1 (16.0M) ROOT LEAK: 0x104726000 [16777216]
      1 (8.00M) ROOT LEAK: 0x103f26000 [8388608]
      1 (4.00M) ROOT LEAK: 0x103b26000 [4194304]
      1 (2.00M) ROOT LEAK: 0x103926000 [2097152]
      1 (1.00M) ROOT LEAK: 0x103826000 [1048576]
      1 (512K) ROOT LEAK: 0x1037a6000 [524288]
      1 (256K) ROOT LEAK: 0x103766000 [262144]
      1 (128K) ROOT LEAK: 0x103746000 [131072]
      1 (64.0K) ROOT LEAK: 0x103735000 [65536]
      1 (32.0K) ROOT LEAK: 0x7fa354007800 [32768]
      1 (16.0K) ROOT LEAK: 0x7fa354003800 [16384]
      1 (8.00K) ROOT LEAK: 0x7fa354001800 [8192]
      1 (4.00K) ROOT LEAK: 0x7fa354000800 [4096]
      1 (2.00K) ROOT LEAK: 0x7fa354000000 [2048]
      1 (1.00K) ROOT LEAK: 0x7fa353802000 [1024]
      1 (512 bytes) ROOT LEAK: 0x7fa3535000a0 [512]
      1 (256 bytes) ROOT LEAK: 0x7fa353402fa0 [256]
      1 (128 bytes) ROOT LEAK: 0x7fa353500020 [128]
      1 (64 bytes) ROOT LEAK: 0x7fa353600000 [64]
      1 (32 bytes) ROOT LEAK: 0x7fa353402d40 [32]
      1 (16 bytes) ROOT LEAK: 0x7fa353402eb0 [16]
      1 (16 bytes) ROOT LEAK: 0x7fa353402ec0 [16]
      1 (16 bytes) ROOT LEAK: 0x7fa353500000 [16]
      1 (16 bytes) ROOT LEAK: 0x7fa353500010 [16]
  1. 您可以使用Malloc Debugging Features
© www.soinside.com 2019 - 2024. All rights reserved.