Hey All,
I found this memory leak in CF9.01 and have confirmed it still exists in CF10.
To reproduce, create two .cfm files & hit them in an Apache JMeter test with two threads. I'm using a brand new install of CF10 with inbuilt web server. MemoryLeak.cfm will not acheive 100 requests (GC overhead limit exceeded), where as my NoMemoryLeak.cfm test is up to 500,000 tests and still going without the old gen increasing at all.
Obviously this is not real production code, but on a very large OO app that also uses lots of structs the test server needs rebooting every 2 weeks due to same problem. We are on CF8 at the moment and want to spend AU$50,000 on a 9.01 upgrade with maintenance for a 10.0 upgrade but can't move because of this memory leak.
-- MemoryLeak.cfm
<cfset transient = structNew() />
<cfset base = getTickCount() />
<cfloop from="1" to="10000" index="index">
<cfset transient[hash("#base##index#")] = true >
</cfloop>
<cfoutput>
Done
</cfoutput>
-- NoMemoryLeak.cfm
<cfset transient = structNew() />
<cfloop from="1" to="10000" index="index">
<cfset transient[hash("#index#")] = true >
</cfloop>
<cfoutput>
Done
</cfoutput>
Will do. In the mean-time,
A colleague came up with a solution that involves sub-classing the ColdFusion.Util.Key class and calling keys.clear() We plan to do this via a scheduled task every night. Do you see any obvious problems with this approach?
Field f = Key.class.getDeclaredField("keys");
f.setAccessible(true);
ConcurrentHashMap chm = (ConcurrentHashMap)f.get(k);
chm.clear();
See: http://stackoverflow.com/questions/5898291/coldfusion-util-key-memory- leak-issue-with-structure-keys/9401913 for the full post/details
dave
North America
Europe, Middle East and Africa
Asia Pacific