• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Dec 22, 2009 Dec 22, 2009

Copy link to clipboard

Copied

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>

TOPICS
Advanced techniques

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 23, 2009 Dec 23, 2009

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 23, 2009 Dec 23, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2009 Dec 25, 2009

Copy link to clipboard

Copied

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

Nein. Keine need.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 23, 2009 Dec 23, 2009

Copy link to clipboard

Copied

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

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 23, 2009 Dec 23, 2009

Copy link to clipboard

Copied

Regarding,

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

It is.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2009 Dec 25, 2009

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2009 Dec 25, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 25, 2009 Dec 25, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 25, 2009 Dec 25, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 26, 2009 Dec 26, 2009

Copy link to clipboard

Copied

I have been playing with your test scenario. Whatever combination I used, I couldn't reproduce an out-of-memory error.

You can use my code, or similar, to study memory use during profiling. I include it below.

I indeed ran out of memory, but that was when I experimented by adding 2 memory consuming operations. First, I created the component objects within the loop. Secondly, I stored them in an array. (See the code I commented out).

<cfsetting enablecfoutputonly="Yes" requesttimeout="1800">

<cfset testObj=createobject("component","test")>

<!--- <cfset testObjArray = arrayNew(1)> --->

<!--- Instantiate Coldfusion Administrator CFC and log in --->

<cfset createObject("component","cfide.adminapi.administrator").login("your_admin_password")>

<!--- Instantiate Server Monitor CFC --->

<cfset serverMonitorObj = createObject("component","cfide.adminapi.servermonitoring")>

<!--- Instantiate Java Runtime --->

<cfset runtime = CreateObject("java","java.lang.Runtime").getRuntime()>

<cfloop from="1" to="50000" index="i">

    <cfset returnQuery=testObj.remoteDataGet()>

    <!---

    <cfset testObjArray=createobject("component","test")>

      <cfset returnQuery=testObjArray.remoteDataGet()>

    --->

    <cfif (i-1)/5000 eq int((i-1)/5000)><!--- test at every multiple of 5000 --->

        <!--- Calculate percentage of JVM allocated memory that is free --->

        <cfset freeMemory = runtime.freeMemory()>

        <cfset totalAllocatedMemory = runtime.totalMemory()>

        <cfset fractionFreeMemory = freeMemory/totalAllocatedMemory>

        <cftry>

            <!--- If free memory is less than 5%, disable memory monitoring and profiling --->

            <cfif fractionFreeMemory LT 0.05>) {

                <cfset serverMonitorObj.disableMemoryMonitoring()>

                <cfset serverMonitorObj.disableProfiling()>

                <cfoutput>Memory monitoring and profiling have been disabled, because JVM free memory fell down to #round(fractionFreeMemory*100)#%<br></cfoutput>

                <cfbreak>

            </cfif>

        <cfcatch type="any">

            Error invoking methods in Server Monitor. Bad admin password or server monitor possibly not enabled.

            <br>

            <!--- <cfdump var="#cfcatch#"> --->           

            <cfbreak>

        </cfcatch>   

        </cftry>

    </cfif>

</cfloop>

<br>


<cfoutput>READY</cfoutput>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 26, 2009 Dec 26, 2009

Copy link to clipboard

Copied

LATEST

Oh, perhaps the most important question to start with: what is the JVM heap size of your Coldfusion installation? If it is low, say, less than 100MB, the chance of out-of-memory errors will be high.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2009 Dec 25, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation