这是个Mysql的内存泄漏吗
我做了个简单的测试, 向问下是否是Mysql内存泄漏问题, 还是Valgrind的问题?
Linux机器配置:Linux localhost.localdomain 2.6.21-1.3194.fc7 #1 SMP Wed May 23 22:47:07 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
Mysql : mysql 6.0.0-alpha
Valgrind: valgrind-3.3.0
1. 首先只写一个"Hello World"的测试文件test.cpp
#include </usr/local/mysql/include/mysql/mysql.h> //mysql header
#include <iostream>
using namespace std;
int main(void)
{
return 0;
}//end
编译时加入Mysql LIB库, 引用头文件, 生成test。
g++ test.cpp -Wall -o test -L"/usr/local/mysql/lib/mysql" -lmysqlclient \
-L "/usr/local/mysql/lib/mysql" -lmysqlclient_r -lm -lz ## -L "./lib" -ldbug
test是生成的可执行文件
2.用valgrind工具检测
valgrind --tool=memcheck --leak-check=full --show-reachable=yes -v -q ./test
//发现有一处内存问题
==2405== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 5 from 1)
==2405== malloc/free: in use at exit: 4,436 bytes in 1 blocks.
==2405== malloc/free: 1 allocs, 0 frees, 4,436 bytes allocated. <------------Look here
==2405== For counts of detected errors, rerun with: -v
==2405== searching for pointers to 1 not-freed blocks.
==2405== checked 920,248 bytes.
==2405==
==2405== 4,436 bytes in 1 blocks are still reachable in loss record 1 of 1
==2405== at 0x4A04CBF: calloc (vg_replace_malloc.c:279)
==2405== by 0x3A808D21DF: monstartup (in /lib64/libc-2.6.so)
==2405== by 0x40141B: __gmon_start__ (in /project/txw/TestValgrind_mysql_loaddata/test)
==2405== by 0x3A7FC032F1: (within /lib64/libresolv-2.6.so)
==2405==
==2405== LEAK SUMMARY:
==2405== definitely lost: 0 bytes in 0 blocks.
==2405== possibly lost: 0 bytes in 0 blocks.
==2405== still reachable: 4,436 bytes in 1 blocks.
==2405== suppressed: 0 bytes in 0 blocks.
Profiling timer expired
3. 当我将Mysql库, 头文件去掉后,重新make , 用Valgrind检查, 则没有这个问题。
请教各位大大!!!!!