Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-04-13
6
Medium Priority
?
966 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
Vim Reference Guide

Vim is a powerful text editor favored by many sysadmins and developers - here are some commands that you'll want to keep in your back pocket!

 

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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

670 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