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: Templates are removed from cache, therefore recompiled. Original assembly can't be unloaded #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When publishing over a period of time, the memory consumed by the publisher 
process is seen to increase, and is not reclaimed. 

Cause: Razor templates are compiled to assemblies, which are loaded into the 
default app domain. Once loaded into an app domain an assembly remains there 
for the lifetime of the app domain. The caching strategy of the razor mediator 
is such that on exceeding a configured cache timeout, a template is removed, 
which means that on its next invocation a new assembly will be compiled and 
loaded. 

Original issue reported on code.google.com by dominic....@gmail.com on 25 May 2013 at 5:49

GoogleCodeExporter commented 9 years ago
Assemblies don't get unloaded from appdomains. Because of this fact, a 
timeout-based caching strategy is inappropriate. 

Andreas Johannsen looked at the possibilities of creating appdomains, so that 
we could control the unloading. Unfortunately, the Tridion objects we need to 
interact with are not serialisable so couldn't be marshalled to a second 
appdomain. This would be a good research area and/or enhancement request for 
Tridion, but is not currently a fruitful direction to follow in fixing this 
issue. 

I propose we alter the caching strategy to be based purely on comparing the 
revision time of the TBB and the compile time of the assembly. This means 
accepting that large amounts of template changes will require restarting the 
publisher. We can try to improve on that later, but this approach would make 
the current issue manageable. 

I'll put together an implementation on a branch so we can see how well this 
would work.

Original comment by dominic....@gmail.com on 25 May 2013 at 5:58

GoogleCodeExporter commented 9 years ago
Fix is in place on the issue9 branch. Looks OK in limited dev testing.

Original comment by dominic....@gmail.com on 25 May 2013 at 6:37

GoogleCodeExporter commented 9 years ago

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