Try putting the line
StartProc:=nil;
in the finaly block before the free library call
toi tell delphi to clear out the memory associated with the
function.
Also try explicity creating a PChar for the mofdule
name and then removing it with FreeMem and GetMem rather then doing the
cast.
Hope this helps.
Nigel.
----- Original Message -----
Sent: Wednesday, January 12, 2000 5:05
PM
Subject: [DUG]: memory loss.
Hello,
I am loading in some dlls into my main application and have
noticed I am getting what I think is a 4k memory leak. At least according to
the task manager.
Everytime I load an application with the following procedure
I lose memory. Can anyone spot anything?
Cheers,
Matt.
type TStartProc = procedure(AppHandle: HWND);
stdcall;
procedure StartProject1; var DllHandle:
HMODULE; StartProc: TStartProc; begin
DllHandle := LoadLibrary(pchar(form1.edit1.text)); if DllHandle
<> 0 then begin
try StartProc :=
GetProcAddress(DllHandle,
'Start'); if Assigned(StartProc)
then
begin
StartProc(Application.Handle);
end else showmessage('notassigned');
finally
form1.listbox1.items.add('Freeing
library');
FreeLibrary(DllHandle);
end; end else showmessage('the big
zero'); end;
|