BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

To free or not to free

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Isapi-WebBroker
View previous topic :: View next topic  
Author Message
Richard Bibby
Guest





PostPosted: Sun Aug 20, 2006 2:34 pm    Post subject: To free or not to free Reply with quote



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





PostPosted: Sun Aug 20, 2006 6:10 pm    Post subject: Re: To free or not to free Reply with 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
Richard Bibby
Guest





PostPosted: Sun Aug 20, 2006 7:31 pm    Post subject: Re: To free or not to free Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Isapi-WebBroker All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.