To test this, I created a simple page that creates an instance of a
cfc "Test.cfc". I then call a method in Test.cfc which creates 1000
further instances of Test.cfc and adds them to a "var" scoped variable
within the function. Further, I run a loop which executes this 10,
times, meaning that 10,000 instances of "Test" are created for each
request (see listing below). To really spice things up, I execute this
page 20 times in a row, thus creating 1000 * 10 * 20 = 200000
instances of Test.cfc. See listing below.
What I expected to see is RAM usage spiking then dropping off after
each page request, as garbage collection occurs. I am running
SeeFusion, which reports on jvm memory usage by ColdFusion and this
tells me that this is behaving as expected [i.e. memory is allocated/
deallocated from the heap]. However, the Task Manager tells me a
different story. Basically the RAM assigned to Jrun.exe keeps growing
in a linear fashion, until the server runs out of RAM and grinds to a
halt.
Has anyone else experienced a similar issue and if so do you know of a
resolution? it seems a similar problem to that documented by Mike
Schierbel (http://www.schierberl.com/cfblog/index.cfm/2006/10/12/
ColdFusion_memoryLeak_profiler) , but none of the resolutions he
proposed have had any effect on my server.
FYI, running CF Mx 7.0.2 Standard Edition on a single CPU dual core
Xeon with 2GB of RAM. I have also applied the cumulative Hot Fixes for
7.0.2 .
******************************
LISTING
******************************
--------------------------
Application.cfm
--------------------------
<cfapplication name="LoadTesting" sessionmanagement="true">
--------------------------
LoadTest.cfm
--------------------------
<cfparam name="variables.test"
default="#createObject('component','test').init()#" />
<cfset foo = StructNew()>
<cfparam name="session.counter" default="1">
<cfscript>
for (i=1; i LTE 10;i=i+1){
foo[CreateUuid()] = variables.test.LoadTest();
}
</cfscript>
<!--- this should help, but doesn't --->
<cfset StructClear(variables)>
<cfoutput>done #session.counter# iterations</cfoutput>
<cfif session.counter LTE 20>
<cfset session.counter = session.counter + 1>
<cflocation url="LoadTest.cfm">
<cfelse>
<cfset session.counter = 1>
</cfif>
--------------------------
Test.cfc
--------------------------
<cfcomponent output="false">
<cffunction name="init">
<cfreturn this/>
</cffunction>
<cffunction name="LoadTest" returntype="array">
<cfscript >
var ret = ArrayNew(1);
var i=1;
for(i=1;i LTE 1000;i=i+1 ){
ArrayAppend(ret,CreateObject("component","Test").init());
}
return ret;
</cfscript>
</cffunction>
</cfcomponent>
Steve
Andrew
We have had seefusion running on our server with this software for
probably a year now, and suddenly it started going nuts about 2 weeks
ago and we couldnt figure out why, taking off seefusion made the
problems go away. Maybe you should uninstall it since you can't figure
out this leak with seefusion.
Good luck :)
On Aug 10, 1:05 pm, Andrew Bateman <andrew.bate...@newgency.com>
wrote:
Andrew
Did you get an answer to your problem? I can't believe that no one out
there has an answer! Recently we had a similar problem with JRun using
up more and more memory until it would crashed. We played around with
all sorts of things to try to get it fixed. In the end we think it was
as simple as lowering out simultaneous requests from 20 down to 10.
Perhaps try that.
Please post your resolution if you find one.
Cheers
Matthew
On Aug 12, 9:33 am, Andrew Bateman <andrew.bate...@newgency.com>
wrote:
if you see that kind of performance issue in proudction you would have
2 options.
1. refactor the code
2. get better hardware
in this instance (way too many instances junking up memory) id go for
the refactor option, by using caching and pooling to reduce the no. of
instances per request. If i saw too many requests hitting the site id
proly go down the hardware option. If lots of ppl are hitting my site,
hopefully im making money and can afford the hardware upgrade! :)
obviously theres a point that jrun / jvm / java will just grind down
if you create too many of anything in memory. So my response would be
your code isnt a fair test..
also this line of your code looks to be creating a non-scoped object:
ArrayAppend(ret,CreateObject("component","Test").init());
it could be an issue of the garbage collection not working 100% as
expected because of the lack of scope.
I have seen these jrun memory issues in the past and sometimes it will
use heaps of ram to the point the server will fail. However, it doesnt
happen that often in production and when it does its more gradual...
Pat