Solved

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

Posted on 2009-04-13
6
939 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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