tracker issue : CF-4169991

select a category, or use search below
(searches all categories and all time range)
Title:

Page response byte buffer cannot be Garbage Collected when storing CFC in Session

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Henry Ho / Henry Ho (Henry Ho)

Created: 06/30/2016

Components: Performance

Versions: 11.0

Failure Type: Memory Leak

Found In Build/Fixed In Build: CF11_Final / 2018.0.0.308823

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win All

Vote Count: 2

Problem Description:

If a CFC is stored in Session, its reference to coldfusion.runtime.NeoPageContext prevents pageContext's response from being garbage collected.

Steps to Reproduce:

1. Enable JMX on CF instance - http://boncode.blogspot.ca/2010/04/cf-java-using-free-visualvm-tool-to.html
2. Enable SessionManagement in Application.cfc
3. Prepare an empty Foo.cfc component (e.g. component {} )
4. Hit this following script with Apache JMeter for 1000 times:

<cfset session.foo = new Foo()>
<cfoutput><cfloop from=1 to="100000" index="i" >#rand()# </cfloop></cfoutput>


Actual Result:

ColdFusion will eventually run out of heap because the large page buffer (1,048,600bytes) cannot be garbage collected.

By inspecting Heap Dump in Visual VM, sort by size (descending) in Classes:
1. Double click the first one, which should be `byte[]`
2. In the left Instances panel, sort by Size (descending)
3. Locate one of the repeating instance with size ~1,048,600 bytes, right click, show Nearest GC Root

this     - value: byte[] #1
 <- buf     - class: coldfusion.runtime.CachedBufferedOutputStream, value: byte[] #1
  <- outstr     - class: coldfusion.tagext.io.cache.ehcache.GenericResponseWrapper, value: coldfusion.runtime.CachedBufferedOutputStream #324
   <- response     - class: coldfusion.jsp.JspWriterIncludeResponse, value: coldfusion.tagext.io.cache.ehcache.GenericResponseWrapper #324
    <- response     - class: coldfusion.runtime.NeoPageContext, value: coldfusion.jsp.JspWriterIncludeResponse #1
     <- pageContext     - class: cfFoo2ecfc175958891, value: coldfusion.runtime.NeoPageContext #324
      <- filterChain     - class: coldfusion.runtime.TemplateProxy, value: cfFoo2ecfc175958891 #323
       <- value     - class: java.util.HashMap$Node, value: coldfusion.runtime.TemplateProxy #324
        <- [7]     - class: java.util.HashMap$Node[], value: java.util.HashMap$Node #77122
         <- table     - class: java.util.HashMap, value: java.util.HashMap$Node[] #8314
          <- map     - class: coldfusion.util.FastHashtable, value: java.util.HashMap #8360
           <- mTable     - class: coldfusion.runtime.MemorySessionScope, value: coldfusion.util.FastHashtable #640
            <- value     - class: java.util.Hashtable$Entry, value: coldfusion.runtime.MemorySessionScope #323
             <- [1]     - class: java.util.Hashtable$Entry[], value: java.util.Hashtable$Entry #12973
              <- table     - class: java.util.Hashtable, value: java.util.Hashtable$Entry[] #1527
               <- value     - class: java.util.Hashtable$Entry, value: java.util.Hashtable #1437
                <- [36]     - class: java.util.Hashtable$Entry[], value: java.util.Hashtable$Entry #12972
                 <- table     - class: java.util.Hashtable, value: java.util.Hashtable$Entry[] #1537
                  <- mSessionPool     - class: coldfusion.runtime.SessionTracker, value: java.util.Hashtable #853
                   <- [6934]     - class: java.lang.Object[], value: coldfusion.runtime.SessionTracker class SessionTracker
                    <- elementData     - class: java.util.Vector, value: java.lang.Object[] #10332
                     <- classes     - class: coldfusion.bootstrap.BootstrapClassLoader, value: java.util.Vector #86
                      <- contextClassLoader (thread object)     - class: org.quartz.simpl.SimpleThreadPool$WorkerThread, value: coldfusion.bootstrap.BootstrapClassLoader #1


Expected Result:

ColdFusion should not have a hard reference to the page buffer and the buffer should be garbage collected to free up the heap.


Any Workarounds:

Do not store CFC in session, or lower session timeout to as short as possible.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4169991

External Customer Info:
External Company:  
External Customer Name: Henry Ho
External Customer Email:  
External Test Config: Server Details



Server Product	ColdFusion

Version	11,0,09,299201

Tomcat Version	7.0.68.0

Edition	Developer  

Operating System	Windows 10  

OS Version	10.0  

Update Level	C:/ColdFusion11/test/lib/updates/chf11000009.jar  

Adobe Driver Version	5.1.3 (Build 000094)  



JVM Details



Java Version	1.8.0_92  

Java Vendor	Oracle Corporation  

Java Vendor URL	http://java.oracle.com/

Java Home	C:\Program Files\Java\jdk1.8.0_92\jre  

Java File Encoding	Cp1252  

Java Default Locale	en_US  

File Separator	\  

Path Separator	;  

Line Separator	Chr(13)

User Name	henryho  

User Home	C:\Users\henryho  

User Dir	C:\ColdFusion11\test\bin  

Java VM Specification Version	1.8  

Java VM Specification Vendor	Oracle Corporation  

Java VM Specification Name	Java Virtual Machine Specification  

Java VM Version	25.92-b14  

Java VM Vendor	Oracle Corporation  

Java VM Name	Java HotSpot(TM) 64-Bit Server VM  

Java Specification Version	1.8  

Java Specification Vendor	Oracle Corporation  

Java Specification Name	Java Platform API Specification  

Java Class Version	52.0

Attachments:

  1. July 01, 2016 00:00:00: 1_Capture.PNG
  2. July 01, 2016 00:00:00: 2_testcase.zip

Comments:

I can also reproduce this bug in CF2016 Update 2.
Comment by External U.
2251 | June 30, 2016 05:37:46 PM GMT
(OPTIONAL) Please explain in 25 characters or more how this bug impacts productivity and why you are adding a vote.
Vote by External U.
2256 | June 30, 2016 09:45:50 PM GMT
This used to be an issue back in the CF7/8 days. It caused some very nasty memory issues. I thought it had been fixed around CF9 so I'm surprised to hear it's still an issue! When a CFC is persisted in any scope past the end of the request, there should be no reference to ANY scopes, nor any piece of the page context which has things like servlet filters which can keep hard references to monitoring software, etc.
Comment by External U.
2252 | June 30, 2016 09:45:58 PM GMT
Here's some blog links that detail the issues that CF used to have back in the day that I remember: http://www.coldfusionmuse.com/index.cfm/2006/10/25/variables.memory.leak http://www.cutterscrossing.com/index.cfm/2009/8/6/scope-usage-and-application-scaling http://www.schierberl.com/blog/memory-leaks-part-iii-sessions-and-cfcs/
Comment by External U.
2253 | June 30, 2016 09:54:13 PM GMT
I can also reproduce this bug in CF10 Update 20
Comment by External U.
2254 | July 04, 2016 01:34:20 PM GMT
This involves a big change and will be considered in the next release.
Comment by Vamseekrishna N.
2255 | September 28, 2016 07:07:30 AM GMT