I am using TWebModule with Apache. I am having problems with a memory leak. In the code below is not freeing the ImageStream a memory leak? If I do free it I get an access violation.
procedure TWebModule1.WebModule1WebActionItem8Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
RecNo: Integer;
ImageStream: TmemoryStream;
begin
RecNo := StrToInt(Request.QueryFields.Values['RecNo']);
Master.MoveBy(RecNo - Master.RecNo); // go to right record
ImageStream := TMemoryStream.Create;
with TGraphicField.Create(Master) do
try
FieldName := 'Graphic';
SaveToStream(ImageStream)
finally
Free
end;
ImageStream.Position := 0; // reset ImageStream
Response.ContentType := 'image/jpg';
Response.ContentStream := ImageStream;
Response.SendResponse
end;