Hello everybody.
I would like to ask for an explanation of a strange (for me) behavior of=
the=20
mysqlcppapi library.
It seems that there are memory leaks - but, of course, my testing method=
=20
could be completely wrong.=20
I am the new in this subject so please forgive my ignorance.
I have searched the internet, but I have not found any information conce=
rning=20
the mysqlcppapi and memory leaks so that I post this mail.
1.Main problem:
=09memory leaks
2.Tests description:
The tests I have done are quite simple. I invoke a simple select query w=
ith=20
the use of the mysqlcppapi in a loop with a defined counter (each loop=20
creates a connection to a database, invokes a query and closes the=20
connection) - then I test the size of an allocated memory with the use of=
=20
e.g. a "ps".
I do this with the line:
"mysqlcppapi::Result_Store res =3D query.store();"
a) compiled in
b) commented (not compiled)
3. Results:
a) the size of a used memory does not increase
b) the size of a used memory constantly increases (it is noticeable after=
=20
about 100 iterations)
4. Environment specification:
my system:=09=09Linux SuSe v.8.0
my gcc:=09=09=09gcc-2.95.3-216
my mysqlcppapi:=091.7-2 (I have tested also the latest version 1.9.2-0)
5. The final description:
I use mysqlcppapi version 1.7-2, but I have also tested the version 1.9.=
2-0=20
(the latest at the time of tests) and it behaves in the same way - in=20
addition a segmentation fault occurred when an application was trying to=20
create a connection to a non existing mysql demon (so I returned to the=20
previous version). I have also tested the mysql++ library, but it behaves=
=20
much worse.
I would be very obliged to any suggestions which would help me to solve =
this=20
problem or to understand it.
=20
5. A testing source code:
It is attached.=20
Here I quote only the function which contains all mysqlcppapi invocations=
:
void createConnection(int _loop)
{
// mysqlcppapi::Connection * conn =3D new mysqlcppapi::Connection();
mysqlcppapi::Connection sconn;
mysqlcppapi::Connection * conn =3D &sconn;
// sleep(1);
conn->connect();
conn->ping();
conn->select_database("dicom");
mysqlcppapi::Query query =3D conn->create_Query();
query << "select * from testD where uid > 2 and uid <=3D 3" << ends;
=20
// the following line causes memory leaks - when it is compiled in
mysqlcppapi::Result_Store res =3D query.store();=09=20
conn->close();
// conn->shutdown();
cout << "\r" << "_loop =3D " << _loop << flush;
// cout << "\t res.size=3D" << res.size() << flush;
// delete conn;
};
Thanks in advance.
--
//=09Radoslaw Garbacz
|