Re: SQLQuery usage of RAM
instead why don't you declare your connecion as glabal and create query object only when needed?
Re: SQLQuery usage of RAM
If you're talking about QSqlQuery and QSqlDatabase then you should have no problems and you should not be using pointers or global objects.
If you're talking about sql in general, then it's wrong place to ask the question as answer depends on what you're using :)
In general, query should hold only results of last executed statement.
Unless there's leak in the query object itself, you should not see memory gorowing infinitely.
Re: SQLQuery usage of RAM
kito, to be sincere the software was developed by a former job colegue and I simply don't know why he decided to create global queries >.< In my softwares I always use as you sad.
Quote:
Originally Posted by
Spitfire
If you're talking about QSqlQuery and QSqlDatabase then you should have no problems and you should not be using pointers or global objects.
If you're talking about sql in general, then it's wrong place to ask the question as answer depends on what you're using :)
In general, query should hold only results of last executed statement.
Unless there's leak in the query object itself, you should not see memory gorowing infinitely.
Well, actually I'm [unfortunately] using Borland C++ Builder 6 with ZEOS library, but the documentation is so terrible that I guessed maybe things would be equal in Qt and Builder in this point.
In any case, it's nice to hear about Qt since I'm developing another software in Qt that uses MySQL as well.
Anyway, no problems. I was already figuring out that this wasn't my software's problem =]
Thanks, God bless,
Momergil
Re: SQLQuery usage of RAM
Quote:
If I declare the query as a pointer or an object in a function, as far as I know (by reading the documentation), when the function stop (i.e. go to its end), the query is destroyed and [I image and hope] the memory occupied is released.
No. If you allocate something on the heap, i.e. with then you are responsible for ensuring that it is deleted at the corrected time. If you do not ensure deletion you have the classic memory leak you are describing. You can ensure deletion of QObjects by giving them a suitable parent at creation. QSqlQuery is not a QObject so you have to ensure deletion yourself (in a destructor, explicitly at the end of the function etc.).
There is generally no reason to allocate a QSqlQuery on the heap though.
Re: SQLQuery usage of RAM
Ok Chris,
thanks!
Momergil