I have an issue with my program using much more memory than I think it should
I’ve used valgrind and it has been a godsend for discovering memory problems such as buffer overruns and memory leaks
Problem I have here is that it doesn’t look like its a leak, just usage that is inconsistent with what I think it should be
Is there another tool that you can use to monitor memory usage in the same way you might monitor variable values using a debugger such as gdb?
massif has told me that the lion share of the heap memory is being allocated via this statement:
->98.80% (1,338,700,288B) 0x40341D5: caa (caa.c:196)
the statement being a call to push an element on to a UT_array, e.g.
utarray_push_back(utarr_ctr_pdws, &pdw);
pdw is a pointer to a struct and is a stack variable
So it would seem the memory that UT_array is mallocing isn’t getting freed, but I have another statement a few lines down explicitly doing this:
utarray_free(utarr_ctr_pdws);
The UT_array is just an array of pointers therefore doesn’t need any additional dtor function defined in the UT_ICD helper struct.
If anyone has any experience of using UT_arrays maybe you can shed some light on why its using up so much memory?
valgrind massif is the answer here, its a heap memory analysis tool (see http://valgrind.org/docs/manual/ms-manual.html)