avoid coldfusion hang

Ketan Jetty
enthusiasm for technology

avoid coldfusion hang

1. Create a file. eg. C:/temp/test.csv
2. populate this file with say million lines of sample data. eg. test
3. run the above script
4. you will notice coldfusion eating up the entire JVM memory

This is potential pitfall most programmer fail to realise and force reboot cf servers.

Why does this happen?
Coldfusion is build as a layer on top of Java, coldfusion assumes the process to be a single request and does not release the old query objects.

How to avoid a coldfusion hang
	fileReader = createObject("java", "java.io.FileReader").init("c:/temp/test.csv");
	bufferedReader = createObject("java", "java.io.BufferedReader").init(fileReader);

	{	curLine = '';
		{	curLine = bufferedReader.readLine();
			curLineCheck = IsDefined("curLine");
			if (curLineCheck) {
		} while(curLineCheck);	
	} catch (Exception e) {
		// this indicates end of file, ok to ignore error 

<cffunction name="insertData" returntype="void">
	<cfargument name="line" type="String" required="true">
	<cfquery name="test" datasource="dsnCF">
		insert into someTable (col) values ('#line#')


CF Quick Reference

Ginger CMS
the future of cms, a simple, easy and intutive content management system ... more

cf prototyping engine, generates boilerplate code and ... more

Jrun monitor
monitor and timely auto-restart to avoid Jrun hang ... more

Inheritance Config.
uses OOPs inheritance to create configuration file ... more

Real Estate App.
complete real estate application using data from MLS ... more

Search Engine Lite
create your own search engine for your web site ... more