Solved

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

Posted on 2009-04-13
6
926 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
DevOps Toolchain Recommendations

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

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now