Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C Valgrind:内存泄漏还是没有?_C_Linux_Memory Leaks_Valgrind - Fatal编程技术网

C Valgrind:内存泄漏还是没有?

C Valgrind:内存泄漏还是没有?,c,linux,memory-leaks,valgrind,C,Linux,Memory Leaks,Valgrind,我在我的程序上运行valgrind,得到以下输出(我将省略上面的83个错误,让我知道是否应该将它们包括在日志中): 这是我从valgrind得到的输出,无论我运行程序多长时间,无论是2秒还是2分钟 既然“可能丢失”不会随时间增加,那么假设我没有内存泄漏是否安全 所有的错误似乎都来自libglib,并围绕g_malloc0和g_realloc旋转 可能丢失valgrind中的错误涵盖了涉及指针链的一部分场景。我肯定会追查原因,直到您确认这不是一个问题(至少,您的内存占用不应该增加),因为它可能表明

我在我的程序上运行valgrind,得到以下输出(我将省略上面的83个错误,让我知道是否应该将它们包括在日志中):

这是我从valgrind得到的输出,无论我运行程序多长时间,无论是2秒还是2分钟

既然“可能丢失”不会随时间增加,那么假设我没有内存泄漏是否安全


所有的错误似乎都来自libglib,并围绕g_malloc0和g_realloc旋转

可能丢失
valgrind中的错误涵盖了涉及指针链的一部分场景。我肯定会追查原因,直到您确认这不是一个问题(至少,您的内存占用不应该增加),因为它可能表明代码中存在其他逻辑问题

这篇文章有一个更详细的答案


有关更多信息,您还可以查看valgrind手册中的。

但您的观察结果并不意味着您没有内存泄漏,只是您没有不断增加的内存泄漏。您的程序的内存占用是否会随着时间的推移而增加?@Floris我该如何解决这个问题?
==9723== LEAK SUMMARY:
==9723==    definitely lost: 0 bytes in 0 blocks
==9723==    indirectly lost: 0 bytes in 0 blocks
==9723==      possibly lost: 4,676 bytes in 83 blocks
==9723==    still reachable: 88,524 bytes in 579 blocks
==9723==         suppressed: 0 bytes in 0 blocks
==9723== Reachable blocks (those to which a pointer was found) are not shown.
==9723== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==9723== 
==9723== For counts of detected and suppressed errors, rerun with: -v
==9723== ERROR SUMMARY: 83 errors from 83 contexts (suppressed: 3 from 3)