Copied to clipboard

Flag this post as spam?

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


  • Mathijs 27 posts 60 karma points
    Oct 21, 2011 @ 00:36
    Mathijs
    0

    Excessive ram usage on request node parent Id

    Hi guys,

    I've just finished debugging a poor performing webservice. What the service does is requesting a set of nodes and returning them. So far nothing special.

    Problem however is that when firing just a single request the RAM usage of the server rises excessively. > 2 GB. Where the umbraco application pool normaly runs below 600 mb for the entire application with multiple active users.

    I found out that just one tiny rule in the webservice is the cause for the problem:

    foreach(Node item in itemList) {

    Int32 parentId = node.Parent.Id; 

    }

    Any one experienced this behaviour before? Uncommenting this line in the code speeds up my application like 700 %.

  • Rodion Novoselov 694 posts 859 karma points
    Oct 21, 2011 @ 01:04
    Rodion Novoselov
    0

    Hi. Are there many sibling nodes to the node in question?

  • Rodion Novoselov 694 posts 859 karma points
    Oct 21, 2011 @ 01:05
    Rodion Novoselov
    0

    Sorry, I meant 'child nodes' not siblings.

  • Mathijs 27 posts 60 karma points
    Oct 21, 2011 @ 01:06
    Mathijs
    0

    Well. What's many :-) Generally spoken they have between 50 and 250 siblings.

    Edit: I think you frased your first question right. As parents child nodes are the same as the child node's sibling.

  • Henri Toivonen 77 posts 111 karma points
    Oct 25, 2011 @ 21:33
    Henri Toivonen
    0

    Wish I could say something more helpful but, I have also seen excessive ram usage and poor performance when looping through nodes and going up/down in the tree structure.

    I am yet to find a good solution to this, other than cache the requests.

  • Mathijs 27 posts 60 karma points
    Oct 25, 2011 @ 23:47
    Mathijs
    0

    I solved it by looping down the tree so I'm able to see in the loop it's self in which parent node I'm working. This solved my problem, but of course it's still odd that requesting a Parent.Id is so slow as it is een part of a nodes xml structure within umbraco.config (In other words, requesting a parent id shouldn't do any searching up and down)

  • Thomas 49 posts 78 karma points c-trib
    Oct 29, 2011 @ 15:39
    Thomas
    0

    I think the Parent property itself it populated when you create a node, but it's left "un-initialised", until you access one of it's properties like for example the Id. 
    At that point it then does a full init, loading in all child nodes etc. 

    If you only need the ID, I once did an extention method that fetched the parentId using the Path property on the node. I can't find the code but should be quick to create:
    The path is comma delimited up to the root, e.g.: path="-1,1054,1384"
    So implement as a Nullable int, return null if String.IsNullOrEmpty or -1, otherwise do a Split(',') and return[length-1].

     

Please Sign in or register to post replies

Write your reply to:

Draft