When adding loop of blogs i get OutOfMemoryException in umbraco 7.6.1
i am using the blog in the umbraco starter kit
i insert blog in loop
str has in him very long string
and after 1000 blogs+- i get
public void insert(string str)
{
var blogPost = UmbracoContext.Current.Application.Services.ContentService.CreateContent("myItem", 1076, "BlogPost");
blogPost.SetValue("Introduction", str);
UmbracoContext.Current.Application.Services.ContentService.SaveAndPublish(blogPost);
}
for (int i = 0; i < 50000; i++)
{
insert(str);
}
Server Error in '/' Application.
Exception of type 'System.OutOfMemoryException' was thrown.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.OutOfMemoryException: Exception of type
'System.OutOfMemoryException' was thrown.
Source Error:
Line 17: var blogPost =
UmbracoContext.Current.Application.Services.ContentService.CreateContent("myItem",
1076, "BlogPost"); Line 18:
blogPost.SetValue("Introduction", str); Line 19:
UmbracoContext.Current.Application.Services.ContentService.SaveAndPublish(blogPost);
Line 20: } Line 21:
Source File: c:\users\x7\documents\visual studio
2017\Projects\Umbraco2\Umbraco2\Controllers\EldarController.cs
Line: 19
When adding loop of blogs i get OutOfMemoryException in umbraco 7.6.1
Hi Ori,
during a large import like that I wouldn't do a publish on every object created. Instead I would only save it and then do a publish afterwards.
Don't know if that is the cause of the problem here but would try that out first.
Regards David
is working on a reply...