Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Saving parsed XML in the application scope in Coldfusion 8.0

Posted on 2008-11-11
Medium Priority
Last Modified: 2013-12-24

Our application is developed in Coldfusion 8.0 and uses XML files to store configuration information, such a list of journals offered on our site.  We have previously loaded these files dynamically every time they were needed by calling XMLParse and storing it in standard variable scope memory.  However, this was using a considerable amount of server memory considering an XML file approximately 50 kb in size was being loaded for every page view.  We receive up to 10,000 hits per hour.

I'd like to store these XML files in shared application memory to reduce the amount of memory being used for each request.  To do this, I load the XML file into an application variable if that variable has not yet been defined.  Please see the attached code snippet.

This all works fine... for about 20 minutes.  After about 20 minutes, the application variable seems to be overwritten with garbage.  The appropriate calls to XML element stop working, and instead I get errors such as "journal[i].link is not defined in application.osajournals" or null null The error occurred on line -1.

I have implemented a locking scheme, as shown in the code snippet, but this does not solve the issue.  I have also tracked calls to the XMLParse function in the database, and the XMLParse is NOT being called multiple times.  There is no other code that tries to write to the parsed XML object.  It seems the XML object variable gets corrupted some other way.

Can anyone assist with this?

Josh D.
<cflock name="xml_journal_lock" type="exclusive" timeout="10">
	<cfif NOT isdefined("application.osajournals") OR IsDefined("URL.varReload")>	
		<cfset application.osajournals = XMLParse(expandpath('/include/xml/journallist.xml'))>
<select name="Journals">
	<cflock name="xml_journal_lock" type="readonly" timeout="10">
		<cfloop from="1" to="#ArrayLen(application.osajournals.journal)#" index="i">
			<option value="#application.osajournals.journal[i].link.xmltext#">#application.osajournals.journal[i].displayname.xmltext#</option>

Open in new window

Question by:OSAIT
LVL 36

Accepted Solution

SidFishes earned 1500 total points
ID: 22934075
nothing obvious but it's probably a locking conflict you would try the cflock without the name param and use scope=Application" instead or increase the timeout

perhaps an alternative would be to use a request variable in application.cfm

<cfset request.osajournals = XMLParse(expandpath('/include/xml/journallist.xml'))>

<cfloop from="1" to="#ArrayLen(request.osajournals.journal)#" index="i">
<option value="#request.osajournals.journal[i].link.xmltext#">#request.osajournals.journal[i].displayname.xmltext#</option>

request vars reduce server overhead as they are sent with each http request (and don't have locking issues)


Author Closing Comment

ID: 31515691
I think because we have many other application variables that aren't being locked, something was getting over written.  The request scope won't help us reduce memory usage because it's created new for each request.

Ultimately, we decided to load the XML into the database first, then use standard database methods to display the information.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses

572 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