I have a "OutOfMemoryError: PermGen space" error on my CF 8 server. In my app 1000 templates were loaded into the same local variable (for testing purpose), so once the next one is loaded, the prior one should be available for GC - but this does not happen. I got a memory dump and looked at it with jhat. What I saw was it loads the thousand templates, each with it's own TemplateClassLoader instances. In the TemplateClassLoader it self there is a static reference to all TemplateClassLoader instances (again this is from the jhat). Probably because of this, the instances are hold in memory, so the class objects can not be GC in permgen.
This "holding on memory" only happens if I call a cfscript function in the template once is loaded. If I just load the template but not calling the function, the class objects are GCed and no OOM error occurs.
Any idea what's happening on the (appeared) static reference on the TemplateClassLoader?