Solved

CF8 and cfdocument in pdf > could this cause memory leak?

Posted on 2009-04-13
6
929 Views
Last Modified: 2012-05-06
I have a new web application that makes use of cfdocument to produce pdfs from HTML.  

Over a days use on our production server, I see memory usage of jrun.exe creep up - could use of cfdocument be causing a memory leak on the server?  I am not sure where to look to troubleshoot.

I am guessing the pdf production may be at the root of the trouble, as I email myself an onrequest errors when they happen. Nearly always it is from a template that produces the pdf.
Pseudo code:
 
<cfdocument format="pdf" name="thispdf" orientation="portrait"  fontEmbed = "yes" 	marginTop="0.50"
		marginBottom=".25"
		marginLeft=".50"
		marginRight=".50"
		scale="100"
		>
HTML CODE HERE
</cfdocument>		
 
<!--- Create the file name to return to the client --->
<cfset variables.filename = "#createUUID()#.pdf"> 
	 
<!--- Make the generated pdf open as a separate file (not a cfm file) --->
<cfheader name="Content-Disposition" value="attachment;filename=#variables.filename#">
	
<!--- generate the pdf and send to the subscriber --->
<cfcontent type="application/pdf" reset="true" variable="#toBinary(thispdf)#" />

Open in new window

0
Comment
Question by:akibasho
  • 4
  • 2
6 Comments
 
LVL 16

Expert Comment

by:duncancumming
ID: 24135371
Instead of using cfheader and cfcontent, what if you tried using the SaveAsName attribute of cfdocument?

<cfdocument format="pdf" name="thispdf" orientation="portrait"  fontEmbed = "yes"       marginTop="0.50"
                marginBottom=".25"
                marginLeft=".50"
                marginRight=".50"
                scale="100"
                saveAsName="#CreateUUID#.pdf"
                >
HTML CODE HERE
</cfdocument> 

Open in new window

0
 

Accepted Solution

by:
akibasho earned 0 total points
ID: 24139110
Thanks for your comment - but doesn't saveAsName create a physical file that then needs to be cleaned up (we don't store these pdfs) ?  Are you saying that  cfheader/cfcontent might be the cause of the memory problems on the server?

0
 
LVL 16

Expert Comment

by:duncancumming
ID: 24141133
Just a guess!  I didn't think SaveAsName created a file, I thought it just rendered the PDF in the browser.  Documentation says "The filename that appears in the SaveAs dialog when a user saves a PDF file written to the browser"  - I'm not sure if you automatically get the Save As dialog box, or if that's only the filename that gets created if you go File > Save.  
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:akibasho
ID: 24143058
Well, learn something new every day!  I haven't used that new attribute "saveAsName" and that definitely will improve my code -

So thank you for that.

However, the memory problem on the server turned out to be unrelated to the code completely.

It turns out that the JRE I was using (and came packaged with my CF8 installation file) was JRE jdk1.6.0_07.   I decided to see whether there was a problem with the JRE version - and downgraded my JRE to 1.5.18.  THAT completely solved the problem.  I am now going to get the latest JRE (now 1.6.13 )  off Sun Microsystems and see if I can go back to 1.6 without the memory problems.
0
 
LVL 16

Expert Comment

by:duncancumming
ID: 24143086
You should accept your own comment as the solution here, in case anyone else runs into this problem.
0
 
LVL 16

Expert Comment

by:duncancumming
ID: 24178327
You should probably have accepted your *other* comment as the anser, the one that details how it was all due to the JRE.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question