alex-klock / razor-mediator-4-tridion

Automatically exported from code.google.com/p/razor-mediator-4-tridion
1 stars 4 forks source link

Memory leak: AppDomain assembly resolve handler not unhooked causing template objects to leak. #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The TridionRazorTemplate class initializer contains the following code: 

AppDomain.CurrentDomain.AssemblyResolve += new 
ResolveEventHandler(TemplateAssemblyResolveEventHandler);

This results in every instance of the object being referenced by the AppDomain. 
A new instance is created for every template invocation. 
Although the reference to the object goes out of scope, it remains "reachable" 
from the AssemblyResolve event's delegate list. This means that the 
TridionRazorTemplate can not be garbage collected, and neither can the 
TemplateRenderer and Session that it in turn references. 

Original issue reported on code.google.com by dominic....@indivirtual.com on 1 Jun 2013 at 5:51

GoogleCodeExporter commented 9 years ago
I've submitted a fix for this on branch "issue10". 

This is to implement IDisposable on TridionRazorTemplate, and in the dispose 
method to unhook the event delegate. So far in testing it's looking good. :-) 

Original comment by dominic....@indivirtual.com on 1 Jun 2013 at 5:56

GoogleCodeExporter commented 9 years ago
I have run some test with this fix and I do not see any memory leaks when 
repeating publishing.

I removed cacheTime from the configuration editor and modified to use using 
statement instead of calling Dispose(), these changes in the attached patch 
file.

Original comment by andreas....@indivirtual.com on 3 Jun 2013 at 8:09

Attachments:

GoogleCodeExporter commented 9 years ago
I merged Andreas' patch onto the issue10 branch.

Original comment by dominic....@indivirtual.com on 6 Jun 2013 at 9:37

GoogleCodeExporter commented 9 years ago

Original comment by dominic....@gmail.com on 25 Jul 2013 at 2:13