Ver Fonte

解决数据库内存泄漏问题:CWxAdoPool::GetInstance()引起的。

Jeff há 6 anos atrás
pai
commit
002180ca9c

+ 7 - 1
source/hook/WxAdoInterface/WxAdoImpl.cpp

@@ -137,7 +137,13 @@ DWORD CWxAdoImpl::InitializePool( IN LPCTSTR lpDBSource, IN CONST DWORD &dwDBPor
 /************************************************************************/
 void CWxAdoImpl::ReleasePool()
 {
-	CWxAdoPool::GetInstance()->ReleasePool();
+	CWxAdoPool *pObj = CWxAdoPool::GetInstance();
+	if ( pObj )
+	{
+		pObj->ReleasePool();
+		delete pObj;
+		pObj = NULL;
+	}
 }
 
 /************************************************************************/

+ 7 - 1
source/hook/WxAdoInterface/WxAdoPool.cpp

@@ -18,6 +18,10 @@ CWxAdoPool::CWxAdoPool()
 
 CWxAdoPool::~CWxAdoPool()
 {
+	m_strDBAccount.Empty();
+	m_strDBName.Empty();
+	m_strDBSource.Empty();
+	m_strPassWord.Empty();
 	DestroyAllDBConnections();
 }
 
@@ -114,7 +118,9 @@ void CWxAdoPool::DestroyAllDBConnections()
  
  			//if (pObj->pRecordSet)
  			//	pObj->pRecordSet.Release();
-
+#ifdef _DEBUG
+			OutputDebugString(_T("ɾ³ýÁ¬½Ó³Ø¶ÔÏó\n"));
+#endif
 			delete pObj;
 			pObj = NULL;
 		}

+ 2 - 2
source/hook/WxService/WxService.cpp

@@ -9,7 +9,6 @@
 #define new DEBUG_NEW
 #endif
 
-
 // 唯一的应用程序对象
 
 CWinApp theApp;
@@ -56,7 +55,8 @@ void CALLBACK WorkEndof()
 int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 {
 	int nRetCode = 0;
-
+	
+	//_CrtSetBreakAlloc(582);
 	// 直接获得前景窗口的句柄;
 	HWND hwnd = GetForegroundWindow(); 
 	SendMessage(hwnd , WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(NULL,MAKEINTRESOURCE(IDI_MICON)));