JRUN Creeping Death

ColdFusion Add comments
Many people have had the old creeping death problem, where JRUN just consumes more and more memory until it finally keels over and dies. Often this has been due to a memory leak that a patch has fixed or soimething easy to identifiy like massive cached queries. But we just had a client with the problem, and their server was CFMX7.0.1 and all patched up, so it had to be an application problem. It turned out to be a rather unusual one, so I thought I would blog it. Having spent a considerable time looking at all the usual issues, caching, or lack of, persistent variables, slow running pages, drivers etc, and tweaking code that looked like it might be the cause, I was coming up empty. Then after dumping out the entire session scope for the application, I discovered that the clients shopping cart CFC was persisting itself inside every session, and with over 1200 sessions in use, this was just eating up more and more memory. This handy bit of code, is what will dump out all your sessions. Thanks to Alex @ pixl8.co.uk for his help and putting me onto these handy java methods. <cfscript>
sessiontrackerObj= createObject("java","coldfusion.runtime.SessionTracker");
activesessions = sessiontrackerObj.getSessionCollection(application.applicationname);
nosessions=ListLen(structkeyList(activeSessions));
</cfscript>
<cfoutput>
<h3>Total Sessions : #nosessions#</h3>
</cfoutput>
<cfdump var="#activesessions#">
So the lesson to be learnt here is, watch out what you put in your sessions or other persisted scopes. In this example you only needed a single instance of a CFC to be invoked, and it should be used to populate an external structure in the session. Another example of why using the THIS scope in a CFC is bad. Here is a nice blog on other runtime methods you can use to access and manipulate session data. http://jehiah.com/archive/extended-operations-on-coldfusion-sessions

0 responses to “JRUN Creeping Death”

Leave a Reply

Leave this field empty

Powered by Mango Blog. Design and Icons by N.Design Studio