Skip to main content
Participating Frequently
December 23, 2009
Question

CFC memory leak? Why is this happening? Simple CFC running out of memory...

  • December 23, 2009
  • 5 replies
  • 1901 views

Take a look at this, a very simple cfm and cfc. Start the cfm, which calls the cfc thousands of times. Look at the JVM memory usage: it climbs up and up till ColdFusion slows down and halts with an out of memory error after about ten minutes. I haven't got a clue on how to resolve this...

test.cfm

<cfsetting enablecfoutputonly="Yes" requesttimeout="10000">
<cfset functions=createobject("component","test")>
<cfloop from="1" to="50000" index="i">
  <cfset returnArray=functions.remoteDataGet()>
</cfloop>

<cfoutput>READY</cfoutput>

test.cfc

<cfcomponent>
<cffunction name="remoteDataGet" access="remote" output="false" returntype="query">
  <cfreturn querynew('test','Integer')>
</cffunction>
</cfcomponent>

This topic has been closed for replies.

5 replies

BKBK
Community Expert
Community Expert
December 25, 2009

Re: CFC memory leak? Why is this happening? Simple CFC running out of memory...

With or without VAR, the problem remains. Turn on memory profiling, and all memory gets eaten up... the solution is to turn memory profiling OFF, so yes, this question has been answered (by myself, look at the top). And YES, a bug report is filed.


I ran your exact code, with profiling switched on, with and without using var, and couldn't reproduce the issue in either case. In any case, the problem is apparently with the profiler, not with a "Simple CFC running out of memory". So your description of the problem isn't entirely correct. The test creates CFCs and query objects 50000 times. There is the crux of the problem.

What I know is, garbage collection is unpredictable. It is apparent that, in your test, objects pile up in memory, and don't get garbage-collected quick enough. I can imagine the same thing happening when you turn debugging on.  Server monitoring and debugging are processes that may be processing each and every object your application creates, without allowing the garbage-collector enough room for action.

You may or may not have found a bug. It is worth investigating anyway. That way, we'll know more.

You marked the problem as solved without as much as one word of clarification. Just as well I asked. Otherwise, you would have left a misleading impression.

BKBK
Community Expert
Community Expert
December 25, 2009

Wimpie last logged in two days ago. Yet someone (else?) has just marked this thread as answered. What's going on here?

WimpieAuthor
Participating Frequently
December 25, 2009

With or without VAR, the problem remains. Turn on memory profiling, and all memory gets eaten up... the solution is to turn memory profiling OFF, so yes, this question has been answered (by myself, look at the top). And YES, a bug report is filed.

Inspiring
December 25, 2009

Just in case anyone else comes across this and wants to know what the bug ref is, it's: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=81318

To yhe OP: it's helpful if you cross-ref any bugs you raise back to the forum post relating to them, for anyone else who has the same issue later.

--

Adam

BKBK
Community Expert
Community Expert
December 25, 2009

The cause of the memory leak is obvious. There's just that much straw you can load on the camel's back.

Think var! Then you give Coldfusion at least a chance to offload some of the garbage.

<cfcomponent>
<cffunction name="remoteDataGet" access="remote" output="false" returntype="query">

  <cfset var qry = querynew('test','Integer')>
  <cfreturn qry>
</cffunction>
</cfcomponent>

Inspiring
December 23, 2009

  <cfreturn querynew('test','Integer')>

While probably unrelated to the memory issue, is not "Integer" a reserved word in queries?

Inspiring
December 23, 2009

Regarding,

While probably unrelated to the memory issue, is not "Integer" a reserved word in queries?

It is.

WimpieAuthor
Participating Frequently
December 23, 2009

This is a tough one!! It seems that enabling memory profiling in the coldfusion server monitor eats up all the memory. Turn that off and everything works fine.

Adobe, this needs to be fixed or written in a 24 point bold font in the manual...

Inspiring
December 23, 2009

It might be an idea to raise a bug report: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html.

Also, it's possible for users to annotate the online docs, so it might be an idea to add a comment to the relevant page.

--

Adam

BKBK
Community Expert
Community Expert
December 25, 2009

It might be an idea to raise a bug report: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html.

Nein. Keine need.