I can tell you that it is mostly related to the C or C++ runtime, both
of them are known, in many compilers, for not freeing resources they
have made, for example mingw C++ runtime libstdc++ does not free
deallocated string memory until he wants, which can be a lot of time
after, what you can do is move the conecction, the query creation and
the inster query outside the loop, also try using a template query for
that, so you only need to give the changed arguments
Alex Burton wrote:
> Hello,
>
> I have a simple logging application that needs to be able to run unattended and
> reliably for as long as possible.
>
> The memory that it uses is increasing as it runs.
>
> Here is an simplified example that reproduces the problem.
>
> int main()
> {
> while (true)
> {
> Connection c;
> c.connect("database","localhost","user","pass");
> Query q = c.query();
> q << "INSERT INTO table_name (field_1 , field_2) VALUES ( 1 , 2 ) ;";
> q.execute();
> }
> }
>
> This memory usage of this program gradually rises over time, and has reached tens of
> megabytes.
>
> It makes no difference if I move the connection out of the loop.
>
> I don't think that it is a memory 'leak' as leak detectors can't find any leaks.
>
> Is this normal ?
>
> Alex
>
>