MonoManager Memory Allocation

Forums 💬 NodeCanvas ⚙️ Support MonoManager Memory Allocation

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16335
    sarper
    Participant

      MonoManager allocates around 2KB memory every single frame causing garbage to build over time. Is there a possibility/plan to reduce allocations for future versions?

      #16338
      Gavalakis
      Keymaster

        Hello again,

        Allocations in MonoManager can come from consistently registering/unregistering graphs for updating, thus it depends on the setup you have going on. Do you by any chance use subgraphs which are constantly stopped and restarted for example? Can you please share a bit more information on the graphs you currently have?

        Thank you!

        #16337
        sarper
        Participant

          Below is a Unity profiler capture taken in Deep Profile mode and Managed Allocations Callstacks enabled. Please load it into Unity profiler and check out the last couple frames (I’ve only recorded for a couple seconds to keep file size low). There is about 2.4kb of allocations in a rather simple single behavior tree. I hope I am doing something wrong for I’m planning to use nodecanvas for more agents 🙂 Thank you.

          https://drive.google.com/file/d/1l4ehWj3t31_bsVtcU43UjnEu0gvK1LP_/view?usp=sharing

          #16336
          Gavalakis
          Keymaster

            Hello again,
            Thank you for the profiler data; that was helpful.
            Some of the allocations happening here are unfortunately unavoidable, while others can be improved. For your information:
            1) When using the AutoCast feature with structs (AutoCasting a struct variable to a task parameter that is not of the same type), then allocation can’t be avoided because the variable needs to be value boxed (which creates allocations). Thus while the AutoCast feature is convenient, it also allocates.
            2) When Enabling/Disabling a Sub-Graph node, there is some allocations for writing/reading the mapped variables if any and for enabling/disabling the subgraph. I think I will be able to improve this.
            3) When using CheckEvent condition, every time the CheckEvent condition is enabled/disabled, it allocates because it subscribes/unsubscribes to a c# event (in EventRouter). Subscribing/Unsubscribing to C# events in itself creates allocations. I can probably improve this by changing the sub/unsub to a custom implementation.

            All allocations in your sent profiler data stem from those. The biggest hits are from # 2 and #3. Since #3 is possible to take place more often in a graph, thus I will check this out first for an improvement, but I will also check #2 out of course. #1 is unfortunately still unavoidable though, although the allocations are smaller (30B-60B).

            Thank you!

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