VC++ プログラム (MS VS2008 でビルド) にメモリ リークがあります。これは、MySql DB サーバー (mysql ver 5.5.25a-log) に接続する小さなテスト アプリです。アプリはmysql cコネクタver.を使用しています。6.0.2。(「mysqlclient.lib」とリンク)、検索だけで動作しますが、124 バイトのメモリ リークがあります。ビジュアル リーク ディテクターのコール スタックは、それを「my_thr_init.c」ファイルまでトレースします。私のコード:
MYSQL realData;
MYSQL *myData=NULL;
//this is done in InitInstance
myData = mysql_init(&realData);
if ( mysql_real_connect( myData, ip_addr, user, pwd, NULL,0,NULL,0))
{
AfxMessageBox(_T("Connected!"));
}
else {
AfxMessageBox(mysql_error(myData));
}
//and this is done in ExitInctance
if(myData!=NULL) {
TRACE("ExitInstance - closing myData\n");
mysql_close( myData );
mysql_library_end();
myData=NULL;
}
アプリを閉じると、これは出力ウィンドウからのものです。
...
ExitInstance - closing myData
Detected memory leaks!
Dumping objects ->
{2720} normal block at 0x05AAB830, 124 bytes long.
Data: < 0;+ > 02 00 00 00 00 00 00 00 30 3B 2B 01 FF FF FF FF
Object dump complete.
The thread 'Win32 Thread' (0x98c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x828) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x424) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xb6c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xdcc) has exited with code 0 (0x0).
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 2711 at 0x05AAB830: 124 bytes ----------
Call Stack:
g:\bs\connector-c-vs2008-32bit\src\mysql-connector-c-6.0.2\mysys\my_thr_init.c (330): HCCAdmin.exe!my_thread_init + 0x9 bytes
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp (109): HCCAdmin.exe!_AfxThreadEntry + 0xF bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c (348): HCCAdmin.exe!_callthreadstartex + 0xF bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c (331): HCCAdmin.exe!_threadstartex
0x74AD33AA (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77139EF2 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77139EC5 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
02 00 00 00 00 00 00 00 30 3B 2B 01 FF FF FF FF ........ 0;+.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 DC 01 00 00 E4 01 00 00 F0 01 00 00 ........ ........
F8 3A 2B 01 FF FF FF FF 00 00 00 00 00 00 00 00 .:+..... ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
34 0C 00 00 01 00 00 00 00 00 00 00 00 00 00 00 4....... ........
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 3C F7 4A 06 00 00 00 00 ....<.J. ........
Visual Leak Detector detected 1 memory leak (10178 bytes).
Largest number used: 219192 bytes.
Total allocations: 2113741 bytes.
Visual Leak Detector is now exiting.