This section addresses a common confusion among Insure users.
Insure does not report what would be a
LEAK_SCOPE
error when it occurs in the function main . To illustrate
why, I will use the following simple example.
#include <stdlib.h>
main() {
char *ptr = malloc(10);
return (0);
}
This may look like a memory leak, but it really is not. The pointer
ptr points to the block of memory allocated by the call
to malloc until the program leaves the function's
scope. However, at that point, the program has terminated and the memory
is freed by the OS. There is never a point during program execution where
there is not a valid pointer to the block, which would allow it to be freed.
Since there is always a valid pointer to the block of memory while the
program is running, it is not leaked. This is
classified by Insure as an outstanding allocated
memory block. For more information on this topic, see the
"leak" summaries
section of the Insure++ User's Guide.
If you are interested in seeing such blocks
reported, you can simply add the option
insure++.summarize outstanding
to your .psrc file and run your program again.
Insure will then print
a report of all outstanding memory blocks with allocation stack traces.
For more information .
call (888) 305-0041, fax (626)305-9048, or
email quality@parasoft.com
|