Re: memory leak in gtk



I have used mtrace to check for memory leaks. In this simple
application there are more than 5000 memory allocation which is not
freed.

Note that just a dynamic memory allocation that isn't freed before the
application terminates is not a leak, in case there still exists a way
to access that allocation through static variables (or variables local
to main()). You wouldn't call a "static int[10000]" a leak, would you?
Nor should you then consider a "static int *p; main (void) { p =
malloc(10000); return 0;}" a leak.

A leak, by definition, is an allocation that is done repeatedly while
the program is running, maybe while the user is performing some
repetitive task in the application, and to which no accessible pointer
remains. For an allocation to be classified as a leak the allocation
should be performed again and again from the same point in code, in a
similar context, and forgotten. All this IMHO, of course.

--tml



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]