简体   繁体   English

Valgrind 报告 SDL2 的内存泄漏

[英]Valgrind reports memory leaks of SDL2

This is my first time working with vlagrind and I am wondering if those errors are something sirious, I should worry about or just ignore them.这是我第一次使用 vlagrind,我想知道这些错误是否严重,我应该担心还是忽略它们。 My program is just simple SDL2 2D space game and i have no clue where those memory leaks could come from.我的程序只是简单的 SDL2 2D 空间游戏,我不知道这些内存泄漏可能来自哪里。

==9173== Conditional jump or move depends on uninitialised value(s)
==9173==    at 0xA0E1343: ??? (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0xA0215E7: llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0x9E8BD75: llvm::FPPassManager::runOnFunction(llvm::Function&) (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0x9E8BFF2: llvm::FPPassManager::runOnModule(llvm::Module&) (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0x9E8C49F: llvm::legacy::PassManagerImpl::run(llvm::Module&) (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0xAFD7B34: llvm::MCJIT::emitObject(llvm::Module*) (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0xAFD7F1D: llvm::MCJIT::generateCodeForModule(llvm::Module*) (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0xAFD86AD: llvm::MCJIT::finalizeObject() (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0xAF9C87F: LLVMGetPointerToGlobal (in /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1)
==9173==    by 0x84B0041: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==9173==    by 0x84A49EF: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==9173==    by 0x8490937: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)

And here it is mentioning some memory leak.这里提到了一些内存泄漏。 But i have checked my code for leaks so many times that i think it must be in SDL library.但是我已经多次检查我的代码是否有泄漏,我认为它必须在 SDL 库中。

17 bytes in 1 blocks are definitely lost in loss record 10 of 1,977
==9173==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==9173==    by 0x4EC85A6: _XlcDefaultMapModifiers (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==9173==    by 0x4EC897A: XSetLocaleModifiers (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==9173==    by 0x4923824: ??? (in /home/coder/Desktop/game/libSDL2-2.0.so.0)
==9173==    by 0x492A45A: ??? (in /home/coder/Desktop/game/libSDL2-2.0.so.0)
==9173==    by 0x48FCF6A: ??? (in /home/coder/Desktop/game/libSDL2-2.0.so.0)
==9173==    by 0x486C8E6: ??? (in /home/coder/Desktop/game/libSDL2-2.0.so.0)
==9173==    by 0x10972A: main (projekt.c:115)
==9173== 
==9173== 112 (56 direct, 56 indirect) bytes in 1 blocks are definitely lost in loss record 1,922 of 1,977
==9173==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==9173==    by 0x880D07E: ???
==9173==    by 0x8488C3B: ???
==9173==    by 0x84737A5: ???
==9173==    by 0x847386C: ???
==9173==    by 0x8474479: ???
==9173==    by 0x8437A33: ???
==9173==    by 0x843A35C: ???
==9173==    by 0x84352BC: ???
==9173==    by 0x83F8357: ???
==9173==    by 0x841C33D: ???
==9173==    by 0x8419C76: ???
==9173== 
==9173== LEAK SUMMARY:
==9173==    definitely lost: 73 bytes in 2 blocks
==9173==    indirectly lost: 56 bytes in 1 blocks
==9173==      possibly lost: 0 bytes in 0 blocks
==9173==    still reachable: 330,333 bytes in 2,678 blocks
==9173==         suppressed: 0 bytes in 0 blocks

Could someone explain me what those errors mean?有人能解释一下这些错误是什么意思吗?

This kind of library will always have some leaks, unfortunately.不幸的是,这种库总会有一些泄漏。 You can check this post for further details or find more answers on the SDL / OpenGL / Any graphic library you want, but long story short, it will almost always happen.您可以查看这篇文章以获取更多详细信息或在 SDL/OpenGL/任何您想要的图形库上找到更多答案,但长话短说,它几乎总是会发生。 All the leaks you should focus on are the ones which are traced back to the code you wrote yourself.您应该关注的所有泄漏都是可以追溯到您自己编写的代码的泄漏。

I recommend launching valgrind --leak-check=full --show-reachable=yes instead of just valgrind , it will display your errors more precisely.我建议启动valgrind --leak-check=full --show-reachable=yes而不是valgrind ,它会更准确地显示您的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM