How to avoid a ColdFusion server hang
1. Create a file. eg. C:/temp/test.csv2. 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 a potential pitfall, which will cause JRun to not release memory and lead to using up all memeory till the server becomes unresponsive. 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.
A sample code to create a ColdFusion server Hang
<cfscript>
fileReader = createObject("java", "java.io.FileReader").init("c:/temp/test.csv");
bufferedReader = createObject("java", "java.io.BufferedReader").init(fileReader);
try
{ curLine = '';
do
{ curLine = bufferedReader.readLine();
curLineCheck = IsDefined("curLine");
if (curLineCheck) {
insertData(curLine);
}
} while(curLineCheck);
} catch (Exception e) {
// this indicates end of file, ok to ignore error
}
bufferedReader.close();
fileReader.close();
</cfscript>
<cffunction name="insertData" returntype="void">
<cfargument name="line" type="String" required="true">
<cfquery name="test" datasource="dsnCF">
insert into someTable (col) values ('#line#')
</cfquery>
</cffunction>
Ginger CMS
the future of cms, a simple and intuitive content management system ... ASP.NET MVC Application
best practices like Repository, LINQ, Dapper, Domain objects ... CFTurbine
cf prototyping engine, generates boilerplate code and views ... Search Engine LITE
create your own custom search engine for your web site ... JRun monitor
monitors the memory footprint of JRun engine and auto-restarts a hung engine ... Validation Library
complete validation library for your web forms ...
the future of cms, a simple and intuitive content management system ... ASP.NET MVC Application
best practices like Repository, LINQ, Dapper, Domain objects ... CFTurbine
cf prototyping engine, generates boilerplate code and views ... Search Engine LITE
create your own custom search engine for your web site ... JRun monitor
monitors the memory footprint of JRun engine and auto-restarts a hung engine ... Validation Library
complete validation library for your web forms ...