我使用的libmysql在一个项目中,我总是看到确切的泄漏总结“仍可达:21块73944个字节”在Valgrind的每一次,它不应该存在。 后来我从这个测试此示例程序的链接 :
/* Simple C program that connects to MySQL Database server*/
#include <mysql.h>
#include <stdio.h>
main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "root";
char *password = "PASSWORD"; /* set me first */
char *database = "mysql";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
/* send SQL query */
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);
/* close connection */
mysql_free_result(res);
mysql_close(conn);
}
当我跑这跟Valgrind的,我仍然得到:
==22556== LEAK SUMMARY:
==22556== definitely lost: 0 bytes in 0 blocks
==22556== indirectly lost: 0 bytes in 0 blocks
==22556== possibly lost: 0 bytes in 0 blocks
==22556== still reachable: 73,944 bytes in 21 blocks
==22556== suppressed: 0 bytes in 0 blocks
- 这是一个隐忧原因?
- 这是一个的libmysql错误?