gpt4 book ai didi

c - Valgrind显示内存泄漏,现在该怎么办? R:C()扩展

转载 作者:行者123 更新时间:2023-12-02 03:40:07 25 4
gpt4 key购买 nike

我已经编写了一个由R .C()函数调用的外部C函数。为了检查是否没有内存泄漏,我使用来自Ubuntu的valgrind进行下一个调用。

R --debugger=valgrind --vanilla < Desktop/eraseme.R

而且我没有错误。但是我确实收到了内存泄漏的通知。
==16347== HEAP SUMMARY:
==16347== in use at exit: 30,440,904 bytes in 13,097 blocks
==16347== total heap usage: 29,644 allocs, 16,549 frees, 134,692,871 bytes allocated
==16347==
==16347== LEAK SUMMARY:
==16347== definitely lost: 120 bytes in 2 blocks
==16347== indirectly lost: 480 bytes in 20 blocks
==16347== possibly lost: 0 bytes in 0 blocks
==16347== still reachable: 30,440,304 bytes in 13,075 blocks
==16347== suppressed: 0 bytes in 0 blocks
==16347== Rerun with --leak-check=full to see details of leaked memory

但是,我不知道如何查找泄漏的来源。输出显示我应该使用 --leak-check=full选项运行它,但是该选项不可用。

我如何找到泄漏的来源?考虑到我正在运行R脚本,我必须对 Valgrind进行哪个调用?

感谢您的时间。

编辑:当我说该选项不可用时,我的意思是我在寻找它们时只有这个选项。
--arch                --help                --min-vsize           --no-restore-history  --silent
--args --interactive --no-environ --no-save --slave
--debugger-args --max-nsize --no-init-file --no-site-file --vanilla
--encoding --max-ppsize --no-readline --quiet --verbose
--file --max-vsize --no-restore --restore --version
--gui --min-nsize --no-restore-data --save

编辑:所以确实R即使 C()函数正确也显示内存泄漏。

最佳答案

@MartinMorgan是对的!即使我运行了一个非常愚蠢的脚本,只有1+1,我仍然得到如上所述的最小内存泄漏。

关于c - Valgrind显示内存泄漏,现在该怎么办? R:C()扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20621282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com