I need help detecting a memory leak
Hi:
I've written this program that does in general lines does the following.
1) Defines this class Proc with a pointer to a generic class I've written called A (private variable in Proc.h declared as A *a).
2) According to user input I need to crete a child (of A) Class B or C. Each of these classes contain a variation of a variable of the type QVector < QVector <qreal> > data . So the code for this creation (in a function inside a Proc object) goes like this: C *c = new C (parmeters); a = c;
3) When the B or C classes are constructed data is initialized again according to user input.
4) the actual process the program needs to run basically updates over and over again data in these classes (B or C) . However here (and not before this process begins) I notice a 20Mb (using the windows task administrator) increase of the memory consumed.
5) After the updating process is done, the user might change a value. Then the program recreates the class deleting the previous implementation (the line here is simply delete a) and then creates a new C or B object. Then the updating process is run again but again I notice the 20Mb increase in memory.
However here is what I don't get if all of the variables used by the function that does the updating are local.. how can the memory increase?
I thought all local variables are automatically deleted (memory returned) when the function ends its execution.
I would really appreaciate any help.
Thanks
Re: I need help detecting a memory leak
Of course some code would be very helpful. Other than that, there is always Valgrind
Re: I need help detecting a memory leak
HI:
Valgrind is no use in windows as far as I could tell. And I don't know squat about linux or the like to change my os because of this. But thanks anyway for the suggestion. Besides looking info I've read in an ubuntu forum that apparently Valgrind gives wrong info on Qt programs because of the way it manages memory.
The problem with posting code is that it is too mcuh. But I´ll try to put up the parts that matter.
On the mean time what is the proper way of deleting or destroying a variable of the QVector< QVector <qreal> > var, sort.
Re: I need help detecting a memory leak
The increase of memory usage doesn't mean you have a leak. Try continuing the expansion until you reach the physical amount of memory in the machine and see if the usage continues to grow. Maybe the operating system is simply keeping the memory reserved for your process until some other process requests it. That's what Linux tends to do, by the way and it's perfectly fine. Maybe newer Windows systems do that as well.