When I ran my NS2 simulation with valgrind, I got the following error report:
==25876== Use of uninitialised value of size 8
==25876== at 0x3834AC85C0: profil_counter (in /lib64/tls/libc-2.3.4.so)
==25876== by 0x3834A2E2AF: (within /lib64/tls/libc-2.3.4.so)
==25876== by 0x3835ADAD2F: (within /usr/lib64/libstdc++.so.6.0.3)
It occurs from time to time. It seems that only happens when running on a 64 bit system.
I think the possible reason is the simulator is compiled with flag -pg because the field "profil_counter" is used by gcc for profiling. Got no solution yet.
2009年4月28日星期二
2009年2月4日星期三
Profiling Memory Usage for NS2 Simulation
I am using ns2 to simulate peer-to-peer networking. However, it turns out that the simulator consumes much more memory than I expected. I am sure that my algorithm could not use so much memory. What's happening during the simulation.
I tried dmalloc, but it seems that the dmalloc supporting in ns2 is out-of-data and causes some error. Finally I gave up dmalloc and turned to valgrind.
I used valgrind to detect memory leaks and errors. Today I learned that it can also do memory usage profiling.
First, you have to pass '-g' option to compiler and re-make ns2. It is recommended to remove any optimization flags when debugging.
Then run your program by typing "valgrind --tool=massif ns test_script.tcl". BTW, I recommend u to specify a threshold for massif by using "valgrind --tool=massif --threshold=0.01 ns test_script.tcl" to get more detailed information.
massif will generate a report in current directory. The default name is massif.out.pid, where pid is the process number.
massif.out is a plain text file. Though u can read it directly, there is another helpful tool, ms_print to gather information in the report and print it more readable. Use ms_print --threshold=0.01 massif.out to format the report.
The output of ms_print is very easy to understand and the online document of valgrind has a detailed description about that. Please refer to http://valgrind.org/docs/manual/ms-manual.html
I tried dmalloc, but it seems that the dmalloc supporting in ns2 is out-of-data and causes some error. Finally I gave up dmalloc and turned to valgrind.
I used valgrind to detect memory leaks and errors. Today I learned that it can also do memory usage profiling.
First, you have to pass '-g' option to compiler and re-make ns2. It is recommended to remove any optimization flags when debugging.
Then run your program by typing "valgrind --tool=massif ns test_script.tcl". BTW, I recommend u to specify a threshold for massif by using "valgrind --tool=massif --threshold=0.01 ns test_script.tcl" to get more detailed information.
massif will generate a report in current directory. The default name is massif.out.pid, where pid is the process number.
massif.out is a plain text file. Though u can read it directly, there is another helpful tool, ms_print to gather information in the report and print it more readable. Use ms_print --threshold=0.01 massif.out to format the report.
The output of ms_print is very easy to understand and the online document of valgrind has a detailed description about that. Please refer to http://valgrind.org/docs/manual/ms-manual.html
订阅:
博文 (Atom)