简体   繁体   English

valgrind需要永远找到内存泄漏,但程序在没有valgrind的情况下运行需要几秒钟

[英]It is taking forever for valgrind to find memory leaks but its takes seconds for the program to run without valgrind

I am using valgrind to find memory leaks on my program however it is taking a long time and its loading. 我正在使用valgrind来查找我的程序中的内存泄漏但是它需要很长时间才能加载。 When I run the program without valgrind it takes second, what is the problem and what should I look for in the code. 当我在没有valgrind的情况下运行程序时,它需要第二个,问题是什么以及我应该在代码中查找什么。

There is no problem as far as I can see unless you can verify an infinite loop or some other run-time error ... Valgrind basically acts like a virtual machine or virtual execution environment running the program, watching all variables, memory allocations, etc., etc. and therefore will run quite a bit slower than native code. 除非你可以验证无限循环或其他一些运行时错误,否则我没有问题... Valgrind基本上就像运行程序的虚拟机或虚拟执行环境,看着所有变量,内存分配等等因此,它将比本机代码运行得慢一些。 You'll get the same effect if you ran your program inside a debugger like gdb and set it to watch every writable memory location. 如果在像gdb这样的调试器中运行程序并将其设置为监视每个可写内存位置,您将获得相同的效果。

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

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