GraphUpdateObject Pooling


I am generating a lot of garbage from GraphUpdateObjects and have been trying to pool them.

Due to the fact that they are not immediately used (especially when “Batch Graph Updates” is switched on) I was getting a lot of problems where I believe I was modifying them before plugin was done with them.

I tried quite a few workarounds, but in the end I added a “FinishedApplying” bool to the GraphUpdateObejct class itself (default to true). I set this to false when I set up my GUO, it then gets set to true inside void IUpdatableGraph.UpdateArea (GraphUpdateObject o) of GridGenerator.cs, which I believe is when all the work with that GUO is finished? I can then decide whether a GUO can be re-used based on this flag.

This seems to let me pool them correctly without any errors, but I just wanted to check that the point I am setting my flag is indeed the end of the GUO being used by your code?

Perhaps there is a better way of doing this that you can add to the pathfinding engine itself? I am always loathed to make changes to a Plugin as it can make updates a pain.

Thanks a lot,


Hi again, any thoughts on this?

Hi @aron_granberg ,

I managed to pool GraphUpdateObjects way back in version 4.1.7.

I achieved this by:

=A* Pathfinding Project Changes=

  1. Added a “FinishedApplying” boolean to GraphUpdateObject and initialise it to true.
  2. Set “FinishedApplying” to true at the end of IUpdatableGraph.UpdateArea(GraphUpdateObject o).

=Project Changes=

  1. Spin up a bunch of GUOs on boot
  2. When setting up a GUO for, set FinishedApplying to false.
  3. Only reuse a GUO when FinishedApplying is set to true.

I am now upgrading to 4.2.17 Free before attempting to use the Pro version of the asset I bought a few months ago, but my old method of pooling GUOs no longer works:

Exception: You are trying to update graphs using the same graph update object twice. Please create a new GraphUpdateObject instead.

Is there a reason this error exists? Why can’t a GUO that has finished it’s job be used again? Maybe a Reset function that reset internalStage would be all that is required here?

I can modify the code so I have access to the internalStage, but really I want to have as few modifications as possible to allow me to upgrade more easily in the future (I have already modified the project to include multi tag support). Would it be possible for you to make poolable GUOs a permanent thing in the main release, please?

All the best.


In the current beta there’s no way to pool GUO’s I’m afraid.
You can work around it using your suggested change, though.
Are you using enough of them that this matters in terms of GC pressure?