NodeCanvas consistent memory leaks

NodeCanvas Forums Support NodeCanvas consistent memory leaks

Tagged: 

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #15924
    yotam
    Participant

    there appear to be consistent memory leaks when working with NodeCanvas. unity can go from 1GB to 2.5GB consistent in a matter of a few minutes just clicking and moving the canvas. this memory also does not get cleared and can grow to states that it’s too slow to work with the canvas to be considered functional. how can we get support?

    #15925
    onderzeeer
    Participant

    +1 on this. Unitys memory usage starts growing, and growing fast, as soon as I start to work with the graph view for NodeCanvas. I’m on the latest version.

    In my specific case I’m editing a Behaviour Tree that is Bound (not asset) to a prefab.

    #15941
    Gavalakis
    Keymaster

    Hello guys. I honestly can not reproduce this problem no matter what. :/

    Do you mean editing a graph on a prefab by “Opening The Prefab”?

    What version of Unity and NodeCanvas are you using?

    Please let me know.

    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

    #15947
    onderzeeer
    Participant

    I have a bound BehaviourTree on a prefab. I open the graph editor by using the EDIT BEHAVIOUR TREE button when editing the prefab.

    I can run the graph ingame just fine. It is just when I’m editing the graph in the graph editor that memory starts leaking. It normally takes about 20-30 minutes of continuous work to go from 1.5gb to 2.5gb of used memory and it’s around then that nodes start lagging and become unresponsive when I move them around and connect them to other nodes. Memory continues to leak until I have to restart the Unity editor.

    It is ONLY when I’m actively working in the GRAPH editor, not the Unity editor that this happens, so it seems like it is related to the movement of and interactions with nodes. Closing the GRAPH editor does not release the memory, only closing the UNITY editor does that.

    Unity: 2021.1.23f1
    NodeCanvas: 3.2.1

    I have included a picture of my tree settings. I have not included an image of my tree since memory starts leaking directly from start with an empty tree as a starting point.

    Attachments:
    You must be logged in to view attached files.
    #15950
    yotam
    Participant

    I made a video showcasing the problem in our project. the video started from fresh unity open only clicking on “Edit Behaviour Tree” on a prefab in the open scene to open the editor. in the video you can see the start memory usage going up over a period of 20 min of use from 1.5GB to 3GB. notice in the video that around 13 minutes in i just leave the editor open without doing anything and it keeps going up. after that i close the editor window and keep it closed for 2 min, while it’s closed the memory stops going up, after that i open the window again to show that the editor window continues leaking. i also show how it impacts the usage at around that time clicking and panning the editor with spikes in performance causing lag that makes it unusable or at the very least very frustrating to use. https://drive.google.com/file/d/11895L5IEbp7SpAb2GY8HmgZZzh9MjVRC/view?usp=sharing

    unity: 2020.3.12f1

    nodecanvas: 3.2

    Btw i really like this product. please help us in resolving this issue

    #15956
    bellux
    Participant

    +1

    This saldy makes the asset unusable, and forces me to either stop using it and/or close the Unity Editor every two/three minutes.
    The player build works smoothly and doesn’t seem to be affected.

    NodeCanvas: 3.2.1
    Unity Version:  2020.3.21f1

    I reproduced the issue by simply creating a new Behavior Tree graph, adding a sequence node and nesting two empty actions (no task inside them). The blackboard is empty as well.

    At that point for every Repaint() or similar (moving the mouse around, clicking and/or selecting stuff), the memory constantly increases to the point of freezing the Editor. As others said, entering playmode doesn’t reset it.

    I tried to stress test it (see the attachment), and the memory increases faster (it might be related to the number of nodes? some cache that keeps getting built/added? I have no idea). Sadly, by profiling the Unity Editor I wasn’t able to find out if there was any method responsible for it.

    The problem seems to happen both with Behavior Trees and FSM, Bound or Asset References, so it might be caused by the inner Graph class.

    I really like the asset as well, so please help us in resolving this issue. Thanks!

    Attachments:
    You must be logged in to view attached files.
    #15960
    bellux
    Participant

    Update: it seems Unity’s fault, but the issue persists even with 2021.1.2f1 (it does seem a bit better with the new version, but I’m still not sure about it – and also upgrading might not be a viable option mid-production).
    I tried only invoking the code in GraphEditor.cs, until Editor.Node.cs -> DrawNodeWindow(), and if I comment GuiLayout.Window the leak stops happening.

    There is an open Unity’s issue related to this: https://issuetracker.unity3d.com/issues/guilayout-dot-window-never-releases-old-windows-which-causes-a-memory-leak

    It seems that the issue persists with GUI.Window as well.

    Sadly it’s marked as “Won’t Fix”, so I don’t know if an actual solution would be writing a different method to display floating  and resizeable windows.

    #15961
    bellux
    Participant

    Update: I have tried modifying all Node classes in order to return their preferred size (e.g. calculating their height based on the text’s lines count), and I used this info to manually draw a flexible Node window (with GUI.Box(calculatedWindowRect, …) as the background, instead of GUILayout.Window). The memory issue seemed to stop, but the nodes weren’t always drawn correctly and I sadly can’t achieve more than this now.

    Since this solution is not doable for me, I have tried another workaround:
    – I have kept using GUILayout.Window, but I removed the GUILayoutOptions (the window seems to resize anyways).
    – replaced string.Empty with GUIContent.none
    – Other than that, the “DrawNodeWindow” method is not static anymore (including all functions invoked inside it) and accepts the windowID as parameter, so it can be passed to the GUILayout.Window directly instead of () => {….}.
    It becomes: GUILayout.Window(node.ID, node.Rect, node.NodeWindowGUI, GUIContent.none, StyleSheet.window);

    With this last workaround, the memory increase/leak still happens, but it seems to be lower and slower than before.
    Please let us know if you can help us, since I am still unsure if I can use the asset in my project or if I should opt for something else because of it. Thanks!

    #15966
    Gavalakis
    Keymaster

    Hello again guys and thank you for the extra details. Very helpful.

    Just to clarify something: Are you editing the Prefab with the option “Auto Save” enabled in the Prefab Editor?
    autosave

    If so, I highly recommend disabling auto-save since this is a cause for freezing (since it saves the prefab on every change) and can be the cause of memory increase for the same reason. The prefab will be asked to be saved anyway as soon as you exit the Prefab Editing Mode.

    I will take a look at the GUILayout.Window and other information you guys posted as well.

    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

    Attachments:
    You must be logged in to view attached files.
    #15976
    bellux
    Participant

    Hi, thank you.
    In my use case I am not editing any prefab, so this happens in the usual scene.

    #15980
    yotam
    Participant

    I have “Auto Save” disabled. I usually open the BT from “Edit Behaviour Tree” i have the Behaviour Tree Owner on the root of the prefab i am editing and the BT asset is not bound to the Behaviour Tree Owner but is saved separately in the project.

    #16085
    Enrique
    Participant

    Hello.

    I have been on a long quest to find the proper node editor for our game and realistically after switching over and over I cannot stop returning to nodeCanvas. However, the issue stated here has unfortunately always been the reason I’ve had to stop using it. I used to think this was a bug in nodeCanvas, not Unity, so I was hoping for future versions to fix this but it seems the issue is still present ( naturally, since it isn’t in your package and Unity won’t fix it).

    I have read on the Unity forums that apparently this bug is also affecting other node editors too. It’s been a while since I’ve used any other than nodeCanvas and Behavior Designer mostly. But weirdly, for example, I can’t recall having this experience in Behavior Designer  at all, however. Perhaps this is since I’ve only used it for simple graphs.

    Regardless, since as bellux states this issue seems to be marked as “won’t be fixed” by Unity:

    Is there any chance we might see an update re-adressing how this part of the editor works? Alternatively, have you considered contacting Unity in order to establish if there’s any proposed solution or workaround to their bug which seems to be plaguing many of the best node editors for Unity, including yours?

    Just like bellux I would prefer to stick with nodeCanvas. It is by far the most complete node editor I have tried and I certainly don’t want other solutions after trying quite a few.  These (your tools, including FlowCanvas), seem to offer all we need for our game.

    However, the bug described on this post is very much destroying my productivity unfortunately. I seriously want to keep using this amazing tool but regardless of who the true culprit is (Unity), it is rendering the product quite hard to use too because of how laggy the experience is. Any sort of interaction with the graph can usually cause freezes that might last upwards of seconds (1 to 3 maybe), and this becomes more and more prominent as the memory leak grows larger.

    Any chance we could revive this discussion? I’d really appreciate it! Thank you so much in advance to everybody having invested time on this matter.

    PS: I really do want to emphasize, the tool is fantastic, I do hope we can resolve this!!

     

    Unity: 2021.1.10f1

    NodeCanvas: can’t recall, but updated yesterday so pretty much the latest.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.