Solved

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

Posted on 2009-04-13
6
925 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 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

15 Experts available now in Live!

Get 1:1 Help Now