I have a program (Written in Delphi6) that acts as a mesage server for lots of different serial communications.
It receives input from different serial devices and then sends messages back, writes to a database and/or passes the message(data from the serial device) to another machine.
When a message is processed I record details of the message and what was done with it in a log file. This writing to a log file is causing memory usage to slowly creep up.
The code I am using to create the log is as below (simplified for posting here):
It all works fine, the log is created and appended to OK but memory usage, slowly but consistently, creeps up. If I comment out the Writeln procedure then there is no change in memory usage.
I have run both MemProof and MemorySleuth and neither can find a problem.
There is obviously nothing wrong with the Writeln procedure as I use it all the time and have never come across this problem. I've even copied chunks of this code into a new app, and it runs fine there.
Does anybody have any ideas what the problem could be.
The variables FT & sLine are unique to this procedure so it can't be anything they're doing.
Any suggestions would be greatly received.
Thanks
Matt.
It receives input from different serial devices and then sends messages back, writes to a database and/or passes the message(data from the serial device) to another machine.
When a message is processed I record details of the message and what was done with it in a log file. This writing to a log file is causing memory usage to slowly creep up.
The code I am using to create the log is as below (simplified for posting here):
Code:
const
LOGDIR : String = 'C:\Logs\';
procedure TfrmMain.Write2Log(sSerialData : String);
var
TF: TextFile;
sFileName: String;
sLine: String;
begin
sFileName := FormatDateTime('yyyymmdd', Now) + '.log';
AssignFile(TF, LOGDIR + sFileName);
if not FileExists(LOGDIR + sFileName) then
Rewrite(TF)
else
Append(TF);
sLine := FormatDateTime('hh:mm:ss:zzz', Now) + ' ' + sSerialData;
Writeln(TF, sLine) ;
Flush(TF);
CloseFile(TF);
end;
It all works fine, the log is created and appended to OK but memory usage, slowly but consistently, creeps up. If I comment out the Writeln procedure then there is no change in memory usage.
I have run both MemProof and MemorySleuth and neither can find a problem.
There is obviously nothing wrong with the Writeln procedure as I use it all the time and have never come across this problem. I've even copied chunks of this code into a new app, and it runs fine there.
Does anybody have any ideas what the problem could be.
The variables FT & sLine are unique to this procedure so it can't be anything they're doing.
Any suggestions would be greatly received.
Thanks
Matt.