简体   繁体   English

Valgrind停止输出

[英]Valgrind is hanging with no output

For a method that I am trying to code for one of the classes I have been working on, I am trying to read double values from a file and dynamically set some arrays inside the program with these numeric values. 对于一种我正在尝试为自己正在研究的类之一进行编码的方法,我正在尝试从文件中读取双精度值,并使用这些数值动态设置程序内部的某些数组。

I wanted to check, at least up to the point that I came, whether I have memory leaks or not. 我想至少检查一下我是否有内存泄漏。 However, firing up valgrind just hangs, valgrind seems to work quite heavily since the cpu loading is high, but no output is generated even if I have been waiting for some time now. 但是,启动valgrind只是挂起,由于cpu负载很高,所以valgrind似乎工作得很厉害,但是即使我已经等待了一段时间,也不会生成任何输出。 I have shuffled through the pages of the manual however could not find something useful. 我已经仔细阅读了手册的页面,但是找不到有用的东西。 I compiled valgrind-3.8.0 and using that now. 我编译了valgrind-3.8.0并立即使用它。 And I am firing it the way I have always done as 我以我一直以来的方式射击

valgrind --leak-check=yes --log-file=valgrind_log ./binary_to_execute args_if_any

I could not also find sth useful for this hanging problem on google search. 我也找不到对Google搜寻中这个悬而未决的问题有用的东西。 Any ideas on the reason of this hanging behaviour? 关于这种悬挂行为的原因有任何想法吗?

Edit 1: Here is a timing output from time command for the application 编辑1:这是来自应用程序的时间命令的计时输出

47740 47740

real    0m1.299s
user    0m1.116s
sys     0m0.176s

Edit 2: Here is a link which is more or less the same as the problem that I am experiencing, 编辑2:这是一个与我遇到的问题大致相同的链接,

A message with a similar problem 出现类似问题的消息

Edit 3: I have noticed sth interesting, if the file size that I am trying to read is large this problem occurs, if the size of the files are relatively small, this hanging does not occur, which is also strange to me. 编辑3:我注意到某事很有趣,如果我尝试读取的文件大小很大,则会出现此问题,如果文件的大小相对较小,则不会发生这种挂起,这对我来说也很奇怪。

A large file suggests more work to be done. 较大的文件表明有更多工作要做。 So valgrind needs more time. 因此,valgrind需要更多时间。 Valgrind really is very slow. Valgrind真的慢。

You can easily debug this with the world's best debugger: printf() (only half-kidding.) Simply print something before or after every iteration of your main loop. 您可以使用世界上最好的调试器轻松调试它:printf()(仅适用于半填充)。只需在主循环的每次迭代之前或之后打印一些内容。 If it doesn't show up, valgrind is really hanging somewhere. 如果未显示,则valgrind确实挂在某个地方。 Thoughtful placement of your printf() statements should reveal the exact location where it hangs (if it actually hangs rather than being slow.) 仔细考虑一下printf()语句的位置,可以显示其挂起的确切位置(如果它实际上挂起而不是变慢)。

  1. maybe your program main thread not exit 也许您的程序主线程没有退出
  2. wait valgrind exit 等待valgrind退出

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

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