I had a memory problem when using TSQL classes, because I forgot to empty the TSQLResult object each time I use it, but now I use mysqlresult->Close() to empty it which seems not to work because a little more slowly but my memory is still getting eaten by either the TSQLResult or TSQLRow or TSQLRow.
So which functions should I use to empty the TSQLResult or the others in my memory?
Hi,
You have to use delete, because Query creates the result on the heap via new:for(...) {
TSQLResult* res=server->Query();
// do something with res
delete res;
}
Axel.
Here is my code. I use delete but it is still eating the memory. I attached the class that I use. I use mainly the Getdxdy_subhisto(int, int, int, int, int, int) function. SqlRoot.cxx (3.51 KB) SqlRoot.h (879 Bytes)
I sent the source of my class a week ago. Did anybody take a look at it since then?
The usage of ‘delete TSQLResult object’ helped a bit but there must be something more in the code because it is still eating my memory - although the eating is much slower.
Hi,
you can e.g. use the gObjectTable (see the users guide and http://root.cern.ch/root/html/TObjectTable) mechanism or valgrind (on linux) to check where your mem leak comes from.
Axel.
Yesterday I tried valgrind, but it prints plenty of messages and I read somewhere that it also prints the errors coming from the memory leaks generated by the possibly wrong implementation of TSQL* and TH1* of Root.
I don’t think that my small code would generate so many memory leaks that I got.
I may copy the output of the valgrind here but it is a loooong output. Or I may attach it in a file.
However, I cannot filter which of them comes from my code or Root’s (possibly) bad implementation.