Hi
bin grad drann mein erster eigener Dienst zu proggen. Eigentlich funktioniert alles so wie es soll. Nur eines nicht. Die Speicherauslastung des Services vergrössert sich um ca. 4 KByte pro sekunde... Proportional zu E/A andere, beides im Taskmgr gesehen... Irgendwo hab ich wohl vergessen speicher freizugeben oder so... aber wo???
so sieht mein ServiceExecute aus:
Delphi-Quellcode:
procedure TSisterWatch.ServiceExecute(Sender: TService);
begin
//ShowMessage('OnExecute - begin');
while not Terminated
do
begin
TRY
// try to catch a user
if Username <> '
'
then
begin
// AUTOSCAN
// THIS SECTION IS FOR USER WHO JUST LOGGED IN
if (Username <> GetSession)
or (Welcome = False)
then
begin
Username := GetSession;
// If the logged in user is not on the blacklist it will autoscan now
if not IgnoreUser
then
begin
Welcome := True;
Log('
logged in with IPAddress: '+GetIPAddress);
// get about the users logontime
logontime := Now;
// check if the user already exists in the database
CheckDBforUser(ADOQuery1,ADOStoredProc1);
// Save to database that the user is logged in
UpdateUserInfo(Username, 1);
// get all info from User Table "t_bb_user"
ADOQuery3.Close;
ADOQuery3.Parameters.ParamValues['
@username'] := username;
ADOQuery3.Open;
if ADOQuery3autostart.AsBoolean
then
ScanAndWriteToDB;
// Activate TCP Server
ActivateTCPServer;
end;
end
else if StartManScan
then
begin
try
// check if the user already exists in the database
CheckDBforUser(ADOQuery1,ADOStoredProc1);
ScanAndWriteToDB;
finally
// its very important to reset the variable StartManScan
StartManScan := False;
end;
end;
end
else
Username := GetSession;
EXCEPT
on e:
Exception do
LOG('
FATAL ERROR#@: '+e.
Message);
END;
ServiceThread.ProcessRequests(False);
Sleep(1000);
end;
//ShowMessage('OnExecute - end');
end;
Der ganze Quellcode im Anhang...