Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ori noriani 5 posts 75 karma points
    May 23, 2017 @ 17:16
    ori noriani
    0

    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

    Stack Trace:

    [OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.] System.Xml.XmlDocument.CreateTextNode(String text) +16 System.Xml.XmlDocument.ImportNodeInternal(XmlNode node, Boolean deep) +282 System.Xml.XmlDocument.ImportNodeInternal(XmlNode node, Boolean deep) +228 System.Xml.XmlDocument.ImportAttributes(XmlNode fromElem, XmlNode toElem) +125
    System.Xml.XmlDocument.ImportNodeInternal(XmlNode node, Boolean deep) +116 System.Xml.XmlDocument.ImportChildren(XmlNode fromNode, XmlNode toNode, Boolean deep) +40
    System.Xml.XmlDocument.ImportNodeInternal(XmlNode node, Boolean deep) +144 System.Xml.XmlDocument.ImportChildren(XmlNode fromNode, XmlNode toNode, Boolean deep) +40
    System.Xml.XmlDocument.ImportNodeInternal(XmlNode node, Boolean deep) +144 System.Xml.XmlDocument.ImportChildren(XmlNode fromNode, XmlNode toNode, Boolean deep) +40
    System.Xml.XmlDocument.ImportNodeInternal(XmlNode node, Boolean deep) +144 System.Xml.XmlDocument.ImportChildren(XmlNode fromNode, XmlNode toNode, Boolean deep) +40
    System.Xml.XmlDocument.CloneNode(Boolean deep) +65
    umbraco.SafeXmlReaderWriter.Clone(XmlDocument xml) +59
    umbraco.SafeXmlReaderWriter..ctor(IDisposable releaser, XmlDocument xml, Action1 refresh, Action2 apply, Boolean isWriter, Boolean scoped) +71 umbraco.<>cDisplayClass3.0() +56
    Umbraco.Core.Scoping.ScopeContext.Enlist(String key, Func1 creator, Action2 action, Int32 priority) +178
    umbraco.SafeXmlReaderWriter.Get(IScopeProviderInternal scopeProvider, AsyncLock xmlLock, XmlDocument xml, Action1 refresh, Action2 apply, Boolean writer) +264 umbraco.content.GetSafeXmlWriter() +99
    umbraco.content.UpdateDocumentCache(Document d) +84
    Umbraco.Web.Cache.PageCacheRefresher.Refresh(IContent instance) +94
    Umbraco.Core.Sync.ServerMessengerBase.DeliverLocal(ICacheRefresher refresher, MessageType messageType, Func2 getId, IEnumerable1 instances) +398
    Umbraco.Core.Sync.ServerMessengerBase.Deliver(IEnumerable1 servers, ICacheRefresher refresher, MessageType messageType, Func2 getId, IEnumerable1 instances) +134
    Umbraco.Core.Sync.ServerMessengerBase.PerformRefresh(IEnumerable
    1 servers, ICacheRefresher refresher, Func2 getNumericId, T[] instances) +222 Umbraco.Web.Cache.DistributedCache.Refresh(Guid factoryGuid, Func2 getNumericId, T[] instances) +282
    Umbraco.Web.Cache.DistributedCacheExtensions.RefreshPageCache(DistributedCache dc, IContent[] content) +178
    Umbraco.Web.Cache.CacheRefresherEventHandler.UpdateSingleContentCache(IContent content) +47
    Umbraco.Web.Cache.CacheRefresherEventHandler.ContentService_Published(IPublishingStrategy sender, PublishEventArgs1 e) +144
    Umbraco.Core.Events.TypedEventHandler
    2.Invoke(TSender sender, TEventArgs e) +0 Umbraco.Core.Events.EventDefinition2.RaiseEvent() +25 Umbraco.Core.Events.ScopeEventDispatcher.ScopeExitCompleted() +82 Umbraco.Core.Events.ScopeEventDispatcherBase.ScopeExit(Boolean completed) +32
    Umbraco.Core.Scoping.<>c__DisplayClass6.<RobustExit>b__3() +30
    Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) +54 Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) +93 Umbraco.Core.Scoping.Scope.RobustExit(Boolean completed, Boolean onException) +250
    Umbraco.Core.Scoping.Scope.DisposeLastScope() +227
    Umbraco.Core.Scoping.Scope.Dispose() +78
    Umbraco.Core.Persistence.UnitOfWork.ScopeUnitOfWork.DisposeResources() +46 Umbraco.Core.DisposableObject.Dispose(Boolean disposing) +173 Umbraco.Core.DisposableObject.Dispose() +20
    Umbraco.Core.Services.ContentService.SaveAndPublishDo(IContent content, Int32 userId, Boolean raiseEvents) +1149
    Umbraco.Core.Services.ContentService.SaveAndPublish(IContent content, Int32 userId, Boolean raiseEvents) +36
    Umbraco.Web.UI.Controllers.EldarController.insert(String str) in c:\users\x7\documents\visual studio 2017\Projects\Umbraco2\Umbraco2\Controllers\EldarController.cs:19
    Umbraco.Web.UI.Controllers.EldarController.Index() in c:\users\x7\documents\visual studio 2017\Projects\Umbraco2\Umbraco2\Controllers\EldarController.cs:29
    lambda_method(Closure , ControllerBase , Object[] ) +62
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
    2 parameters) +167
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +27
    System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
    System.Web.Mvc.Async.WrappedAsyncResult
    2.CallEndDelegate(IAsyncResult asyncResult) +29
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
    System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
    System.Web.Mvc.Async.WrappedAsyncResult
    1.CallEndDelegate(IAsyncResult asyncResult) +10
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
    System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
    System.Web.Mvc.Async.WrappedAsyncResult
    1.CallEndDelegate(IAsyncResult asyncResult) +10
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
    System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
    System.Web.Mvc.Async.WrappedAsyncVoid
    1.CallEndDelegate(IAsyncResult asyncResult) +29
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
    System.Web.Mvc.Async.WrappedAsyncVoid
    1.CallEndDelegate(IAsyncResult asyncResult) +22
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
    System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
    System.Web.Mvc.Async.WrappedAsyncVoid
    1.CallEndDelegate(IAsyncResult asyncResult) +29
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
    System.Web.Mvc.<>c__DisplayClassa.<EndProcessRequest>b__9() +22
    System.Web.Mvc.<>c__DisplayClass4.<Wrap>b__3() +10
    System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func
    1 func) +27
    System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Action action) +64 System.Web.Mvc.ServerExecuteHttpHandlerAsyncWrapper.EndProcessRequest(IAsyncResult result) +71
    System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +1511

    [HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.] System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +2421
    System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +77
    System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +25
    System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +20
    System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +462
    System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) +83
    System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName) +11
    ASP.PageViewsEldarcshtml.Execute() in c:\Users\X7\Documents\Visual Studio 2017\Projects\Umbraco2\Umbraco2\Views\Eldar.cshtml:8
    System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198
    System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
    System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
    System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
    System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
    Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +113
    System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
    1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
    1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +52
    System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
    System.Web.Mvc.Async.WrappedAsyncResult
    1.CallEndDelegate(IAsyncResult asyncResult) +10
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
    System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
    System.Web.Mvc.Async.WrappedAsyncVoid
    1.CallEndDelegate(IAsyncResult asyncResult) +29
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
    System.Web.Mvc.Async.WrappedAsyncVoid
    1.CallEndDelegate(IAsyncResult asyncResult) +22
    System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
    System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
    System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
    System.Web.Mvc.Async.WrappedAsyncVoid
    1.CallEndDelegate(IAsyncResult asyncResult) +29
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +576 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +157

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    May 24, 2017 @ 08:50
    David Brendel
    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

Please Sign in or register to post replies

Write your reply to:

Draft