Memcheck,一个带有valgrind的内存错误检测器

Memcheck,一个带有valgrind的内存错误检测器,c,memory-leaks,valgrind,C,Memory Leaks,Valgrind,我有一个小项目,我需要提交,但我得到了一个valgrind错误,我需要帮助 ==11707== Memcheck, a memory error detector ==11707== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==11707== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==11707== Command

我有一个小项目,我需要提交,但我得到了一个valgrind错误,我需要帮助

==11707== Memcheck, a memory error detector
==11707== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==11707== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==11707== Command: test.out test.txt 19
==11707== HEAP SUMMARY:
==11707==     in use at exit: 4 bytes in 1 blocks
==11707==   total heap usage: 110 allocs, 109 frees, 40,992 bytes allocated
==11707==
==11707== 4 bytes in 1 blocks are definitely lost in loss record 1 of 1
==11707==    at 0x483577F: malloc (vg_replace_malloc.c:299)
==11707==    by 0x10986F: run_test_1 (test.c:330)
==11707==    by 0x109D34: main (test.c:466)
==11707==
==11707== LEAK SUMMARY:
==11707==    definitely lost: 4 bytes in 1 blocks
==11707==    indirectly lost: 0 bytes in 0 blocks
==11707==      possibly lost: 0 bytes in 0 blocks
==11707==    still reachable: 0 bytes in 0 blocks
==11707==         suppressed: 0 bytes in 0 blocks
==11707==
==11707== For counts of detected and suppressed errors, rerun with: -v
==11707== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
所以它指的是使用malloc的第330行。现在我还没有找到内存泄漏的确切原因,但似乎每个malloc都被释放了

valgrind是否有可能指由
exit()
引起的内存泄漏?
如果是这样,那么我的任务允许我忽略仅由它引起的内存泄漏

如果不是,我能知道至少是内存还是可以访问的吗?或者其他可能有用的细节


谢谢

它告诉你你肯定有漏洞。您需要更仔细地查看您的代码,看看应该在哪里释放它。