Hi
I have a mysql server:
mysqld Ver 3.23.33 for pc-linux-gnu on i686
I use C API to communicate with database, a simple connection could look
like this:
---------------------- test.c --------------------------
#include <stdio.h>
#include <mysql/mysql.h>
int main()
{
MYSQL *conn;
conn = mysql_init(NULL);
if (!mysql_real_connect (conn, "host", "user", "pass", "database", 0,
NULL, 0)) {
printf("%s\n", mysql_error(conn));
return 1;
}
mysql_close(conn);
return 0;
}
---------------------------------------------------------
and compilation:
gcc test.c -o test -lmysqlclient -g
At the software creating, it's worth using (at least for tests)
functions from header <mcheck.h>. It's very usefull for finding memory
leaks. Now, take a look at second example:
----------------- test2.c ----------------------------------------
#include <stdio.h>
#include <mysql/mysql.h>
#include <mcheck.h> /* mtrace(); muntrace(); */
int main()
{
MYSQL *conn;
setenv("MALLOC_TRACE","/tmp/mtrace.log",1);
mtrace();
conn = mysql_init(NULL);
if (!mysql_real_connect (conn, "host", "user", "pass", "database", 0,
NULL, 0)) {
printf("%s\n", mysql_error(conn));
return 1;
}
mysql_close(conn);
muntrace();
return 0;
}
---------------------------------------------------------
after compilation:
gcc test2.c -o test2 -lmysqlclient -g
program execution:
./test2
and mtrace log parsing:
mtrace test2 /tmp/mtrace.log
I achieve many lines (76 in fact) of places where memory is not freed.
Does anybody knows what is going on ? (it's my fault or it's mysql
functions fault or mtrace fault ;-) ?)
Any help would be appreciated.
-
Jakub Trzetrzelewski
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php