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. 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. 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. Any ideas on the reason of this hanging behaviour?
Edit 1: Here is a timing output from time command for the application
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,
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.
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 reports two types of issues: memory errors and memory leaks. When a program dynamically allocates memory and forgets to later free it, it creates a leak. A memory leak generally won't cause a program to misbehave, crash, or give wrong answers, and is not an urgent situation.
Look for function names and line numbersIf you compile your program with the -g flag, Valgrind will show you the function names and line numbers where errors occur.
A large file suggests more work to be done. So valgrind needs more time. Valgrind really is very slow.
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. If it doesn't show up, valgrind is really hanging somewhere. Thoughtful placement of your printf() statements should reveal the exact location where it hangs (if it actually hangs rather than being slow.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With