System.OutOfMemoryException from Razor.Parse(...)

Jun 1, 2012 at 8:25 AM
Edited Jun 1, 2012 at 8:36 AM

Hi

I have a program that uses RazorEngine and calls Razor.Parse() several times, passing in a strongly-typed model to a very simple view.

However, after 6,491 calls I got this exception:

Exception of type 'System.OutOfMemoryException' was thrown. Stack :    at CompiledRazorTemplates.Dynamic.ebfdbcebbaf.Execute()     at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)     at RazorEngine.Templating.TemplateService.Run(ITemplate template)     at RazorEngine.Templating.TemplateService.Parse[T](String razorTemplate, T model)     at RazorEngine.Razor.Parse[T](String razorTemplate, T model)     at MedicalAuthors.Publish.Helpers.LayoutHelper.CreateLayout[T](String viewName, T model) in C:\development\MedicalAuthors\MedicalAuthors.Publish\Helpers\LayoutHelper.cs:line 39     at MedicalAuthors.Publish.Helpers.LayoutHelper.CreateContent(SupportGroup supportGroup, GenerationContextType context) in C:\development\MedicalAuthors\MedicalAuthors.Publish\Helpers\LayoutHelper.cs:line 31     at MedicalAuthors.Publish.Helpers.EmisReferenceHelper.Publish(SupportGroup supportGroup) in C:\development\MedicalAuthors\MedicalAuthors.Publish\Helpers\EmisReferenceHelper.cs:line 61

 

The template itself is very simple:

 

<h1>@Model.Title</h1>
<div class="content-wrapper">
@Raw(Model.Navigation)
@Raw(Model.Introduction)
@Raw(Model.Body)
</div>

Just wondering if someone could suggest what's going on here and how I can fix it.

Thanks.