|
From: Guilherme L. <li...@fn...> - 2003-08-05 22:44:32
|
Hi,
I am using valgrind 1.9.6 to analyse a small program:
----------------
1 #include <string>
2 using std::string;
3 int main() {
4 string leak("Does this cause a memory leak?");
5 string* ok = new string("This does not cause any memory leaks");
6 delete ok;
7 return 0;
8 }
-----------------
The commands:
> g++ -g -o test test.cpp
> valgrind --leak-check=yes --show-reachable=yes ./test
Shows:
----------------
...(removed)...
==3406== LEAK SUMMARY:
==3406== definitely lost: 0 bytes in 0 blocks.
==3406== possibly lost: 0 bytes in 0 blocks.
==3406== still reachable: 1920 bytes in 1 blocks.
==3406== suppressed: 0 bytes in 0 blocks.
----------------
The traceback points to line 4 in test.cpp source file.
The questions are:
1) Does "still reachable" report a real memory leak?
2) Do "definitely lost" and "possibly lost" reports
always mean memory leaks?
3) Are there situations when "possibly lost" does not
come from a memory leak? If so, can someone post
a code snippet where such a situation has been
isolated?
Thanks,
Guilherme
|