Title:
Page response byte buffer cannot be Garbage Collected when storing CFC in Session
| View in TrackerStatus/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:
- July 01, 2016 00:00:00: 1_Capture.PNG
- July 01, 2016 00:00:00: 2_testcase.zip
Comments: