我用valgrind检查以下语句是否存在内容泄露,按照网上说的在close后增加mysql_library_end()语句,结果还是出现内存泄露,代码如下:
mysql_library_init(0, NULL, NULL);
MYSQL *conn = mysql_init(NULL);
mysql_close(conn);
mysql_library_end();
mysql、mysql-devel、openssl这些库也更新成最新的了,用的centos系统
内存泄露的内容:
==69986== 16,384 bytes in 1 blocks are still reachable in loss record 593 of 593
==69986== at 0x4C2FAA9: realloc (vg_replace_malloc.c:1437)
==69986== by 0x4s8FDAA: CRYPTO_realloc (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x4z8F4FB: OPENSSL_LH_insert (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x4x7517C: err_load_strings (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x4F75532: ERR_load_strings_const (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x509C5B5: ERR_load_ENGINE_strings (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x506D61D: err_load_crypto_strings_int (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x4F8D48B: ossl_init_load_crypto_strings_ossl_ (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x62B120A: __pthread_once_slow (in /usr/lib64/libpthread-2.17.so)
==69986== by 0x4FD8B54: CRYPTO_THREAD_run_once (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x4F8D6ED: OPENSSL_init_crypto (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)
==69986== by 0x4F08DC3: OPENSSL_init_ssl (in /usr/lib64/mysql/libmysqlclient.so.20.3.25)