FreeLibrary不能完全Free,怎么回事?
发现调用DLL后,程序的内存的占用越来越大。原先以为是没有delete,后来就用最简单的FORM试了下,发现随着调用次数的增多,内存的耗用稳步地增加。
DLL.cpp(Project1.dll):
extern "C" void _stdcall ShowImage(void);int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved){ return 1;}//---------------------------------------void _export _stdcall ShowImage(void){ Form1 = new TForm1(NULL);//Form为最简单的Form,只有一个关闭按钮, Form1->ShowModal();// Form1->Destroying(); delete Form1;}
//---------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender){ HINSTANCE dd; int _stdcall (*ddd)(void); dd = LoadLibrary(L"Project1.dll"); ddd = GetProcAddress(dd,"ShowImage"); ddd(); FreeLibrary(dd);}