Memory leak integrity inside cfunction

Googlers, if you have a bunch of heaps with the root coldfusion.runtime.CFDummyComponent to read.

Update 02/22/2011

Mark Asher from MXUnit's fame found the same error in a different context . Its solution includes a large loop over the query, solved by moving from query="name" to from="1" to="#name.recordcount#" index="row" . Another approach that works is to use <cfthread> inside the loop as such:

 <cfloop ...> <cfset threadName = "thread" & createUuid()> <cfthread name="#threadName#"> <!--- do stuff ---> </cfthread> <cfthread action="join" name="#threadName#"> </cfloop> 

This is very effective when you are faced with situations where you need to do something inside the loop, like queries, and <cfmodule> inside <cffunction> so that the memory consumed is only for this iteration.

Old question

Hope someone else can confirm or tell me what I'm doing wrong. I can play OOM sequentially by invoking the oom.cfm file (shown below). Using jconsole, I can see that the request consumes memory and never releases it until completion. It seems that the problem causes a call to <cfmodule> inside <cffunction> , where if I comment on <cfmodule> , all things are garbage collected during the execution of the request.

ColdFusion Version : 9,0,1,274733

JVM Arguments

 java.home=C:/Program Files/Java/jdk1.6.0_18 java.args=-server -Xms768m -Xmx768m -Dsun.io.useCanonCaches=false -XX:MaxPermSize=512m -XX:+UseParallelGC -Xbatch -Dcoldfusion.rootDir={application.home}/ -Djava.security.policy={application.home}/servers/41ep8/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/coldfusion.policy -Djava.security.auth.policy={application.home}/servers/41ep8/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/neo_jaas.policy -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=56033 

Test case

oom.cfm (this calls template.cfm below - Adobe Bug # 85736 )

 <cffunction name="fun" output="false" access="public" returntype="any" hint=""> <cfset var local = structNew()/> <!--- comment out cfmodule and no OOM ---> <cfmodule template="template.cfm"> </cffunction> <cfset size = 1000 * 200> <cfloop from="1" to="#size#" index="idx"> <cfset fun()> <cfif NOT idx mod 1000> <cflog file="se-err" text="#idx# of #size#"> </cfif> </cfloop> 

template.cfm

 <!--- I am empty! ---> 

Update # 2 ( cfthread case by Elliott Sprehn - Adobe ColdFusion Error # 83359 )

 <cfthread name="test"> <cfloop from="1" to="10000" index="i"> <cflog text="This is very bad."> <cflock name="test" timeout="10"> </cflock> </cfloop> <!--- Sleep a very long time (10 minutes) ---> <cfset sleep(600000)> </cfthread> 
+8
coldfusion memory-leaks coldfusion-9
source share
3 answers

I have not come across this before, but here is what I think is happening:

Each time cfmodule is called, a new memory space is created for it (which, as a rule, is IIRC, is the main difference between it and cfinclude). Since you are calling cfmodule inside a function, the cfmodule memory space technically refers to this function memory space. The function memory is protected from garbage collection until the function is executed. Result: filling the heap and you get an OOM error.

I do not think that calling it a memory leak is correct, because it behaves correctly, and when the function completes, the garbage collector can clear the hold of this memory. However, I see how this can be inconvenient.

+5
source share

Unfortunately, this problem manifests itself in a large number of tags. I saw this with cflock inside cfthread. Write a very long loop in cfthread that uses cflock, eventually you run out of memory. It takes a lot of time, but it happens. I’m sure that the storage problem persists in regular queries, but usually you don’t have a loop that runs hundreds of thousands of times using cflock inside, so no one notices.

I registered this error a long time ago, but it was not fixed: http://www.elliottsprehn.com/cfbugs/bugs/83359

The best solution so far is not to use cfmodule inside a loop like this. Custom tags are not really meant to be called 20k times in a single request. Instead, you will want to use UDF. cfmodule is extremely expensive, and using UDF will be noticeably faster.

+3
source share

The following is a discussion of a possible cfc memory leak problem with Coldfusion 9 error: http://forums.adobe.com/thread/1034324?start=0&tstart=0

See this bug report: https://bugbase.adobe.com/index.cfm?event=bug&id=3124148

I don’t think Adobe released a fix for version 9.01, but this problem is supposedly fixed in version 10. For most people, there are workarounds (depending on the size of their problem), which is not much different from the one described here.

0
source share

Source: https://habr.com/ru/post/650806/


All Articles