| View previous topic :: View next topic |
| Author |
Message |
Richard Bibby Guest
|
Posted: Sun Aug 20, 2006 2:34 pm Post subject: To free or not to free |
|
|
Hej,
When writing the following code do I need to free "PDF" at the end of the
code, or is it handled for me?
// Now create a stream to hold the PDF report. OBS!! I think it is
freed after the response has been sent...
PDF := TMemoryStream.Create ;
try
TBlobField(
dsReport.FieldByName('PDFSvarBlob') ).SaveToStream(PDF);
// Now return the report to the browser.
pdf.Position := 0 ;
Response.ContentStream := PDF ; <=== BECAUSE OF THIS
Response.ContentType := 'application/pdf' ;
Response.SendResponse ;
finally
PDF.Free ; <==== DO I NEED THIS?
end ;
Thanks for the help...
/Richard |
|
| Back to top |
|
 |
William Egge Guest
|
Posted: Sun Aug 20, 2006 6:10 pm Post subject: Re: To free or not to free |
|
|
It is freed for you.
I don't think you need the Response.SendResponse Line.
In order to protect memory, I would code your routine like this:
PDF:= TMemoryStream.Create;
try
TBlobField(dsReport.FieldByName('PDFSvarBlob')).SaveToStream(PDF);
pdf.Position := 0 ;
except
PDF.Free;
raise;
end;
Response.ContentStream := PDF ;
Response.ContentType := 'application/pdf' ;
//Response.SendResponse;
Handled:= True;
Bill Egge
ISAPI Tools
http://www.eggcentric.com |
|
| Back to top |
|
 |
Richard Bibby Guest
|
Posted: Sun Aug 20, 2006 7:31 pm Post subject: Re: To free or not to free |
|
|
Thanks.... and I will change code as you suggest.
"William Egge" <begge (AT) eggcentric (DOT) com> skrev i meddelandet
news:44e85f29$1 (AT) newsgroups (DOT) borland.com...
| Quote: | It is freed for you.
I don't think you need the Response.SendResponse Line.
In order to protect memory, I would code your routine like this:
PDF:= TMemoryStream.Create;
try
TBlobField(dsReport.FieldByName('PDFSvarBlob')).SaveToStream(PDF);
pdf.Position := 0 ;
except
PDF.Free;
raise;
end;
Response.ContentStream := PDF ;
Response.ContentType := 'application/pdf' ;
//Response.SendResponse;
Handled:= True;
Bill Egge
ISAPI Tools
http://www.eggcentric.com
|
|
|
| Back to top |
|
 |
|