OutOfMemoryException on Editor with 2 16x16 graph maps

OutOfMemoryException: Out of memory
  at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
  at System.Collections.Generic.List`1[T].set_Capacity (System.Int32 value) [0x00021] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Collections.Generic.List`1[T].EnsureCapacity (System.Int32 min) [0x00036] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Collections.Generic.List`1[T].Add (T item) [0x00010] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at Pathfinding.GraphUtilities.GetContours (Pathfinding.GridGraph grid, System.Action`1[T] callback, System.Single yMergeThreshold, Pathfinding.GridNodeBase[] nodes) [0x00303] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/Core/Misc/GraphUtilities.cs:220 
  at Pathfinding.RVO.RVONavmesh.AddGraphObstacles (Pathfinding.RVO.Simulator sim, Pathfinding.GridGraph grid) [0x00051] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/RVO/RVONavmesh.cs:97 
  at Pathfinding.RVO.RVONavmesh.OnLatePostScan () [0x000ef] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/RVO/RVONavmesh.cs:72 
  at Pathfinding.RVO.RVONavmesh.OnGraphsPostUpdate () [0x00001] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/RVO/RVONavmesh.cs:46 
  at Pathfinding.GraphModifier.TriggerEvent (Pathfinding.GraphModifier+EventType type) [0x000ed] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/Core/Misc/GraphModifier.cs:80 
  at Pathfinding.GraphUpdateProcessor.ProcessGraphUpdates (System.Boolean force) [0x00070] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/Core/Misc/GraphUpdateProcessor.cs:186 
  at Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force) [0x0012a] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:307 
  at AstarPath.PerformBlockingActions (System.Boolean force) [0x0003e] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/Core/AstarPath.cs:881 
  at AstarPath.Update () [0x00029] in /Users/juan/Unity/City/Assets/AstarPathfindingProject/Core/AstarPath.cs:864

Any idea why this is happening? it started happeing all of a sudden when adding/removing street tiles. This ones are tags in one graph grid that happen to be obstacles for ships using tags, and on another grid are simple nodes walkable or not walkable .

Hi

That’s very odd… This might have been fixed in the beta version though, I think there’s been a fix for the GetContours method there.
You could also remove the RVONavmesh script to work around this.

Hello again. After checking my code I saw something I was doing after destroy/build each tile:
AstarPath.active.UpdateGraphs(bcBounds);

I thought maybe calling this too many times could cause the memory exception. Then I removed it and this is what’s happening now, new built tiles after loading map are placed down. If I do a Scan of the graph it gets fixed.

Captura de pantalla 2021-04-30 a las 11.29.29

This is what I do after building the street:Captura de pantalla 2021-04-30 a las 11.30.12

And this is my graph config:

Should I have not removed the
AstarPath.active.UpdateGraphs(bcBounds); ?

Is this the cause this problem is happening?

still trying to solve this.
Please any ideas?

Hi

You probably should not have your node.Walkable = true line there. Only use UpdateGraphs for that. It will take care of updating everything properly.

Hey there, still polishing this. Testing again and realized I need the
node.Walkable = false in the RemoveStreet, but I can take out safely the node.Walkable = true from the AddStreet function as you suggested and seems to work fine.
Just wondering why did we do this and why it worked because I dont understand why was that a problem so I can remember next time.
THanks!

Hi again, sorry to bother you again but I’m still getting the exception:
Captura de pantalla 2021-05-13 a las 12.45.17

What could I do to trace better the reason of this ? Is there some kind of inner log I could provide you?

This seems to be the part is crashing now:
Captura de pantalla 2021-05-13 a las 12.56.34

On the last try there were 2 tiles to tag, on the second got stuck.

I’m pretty sure this is happening because somewhere you are setting a node’s walkability without recalculating that node’s connections. Can you try to disable your code that modifies the graph and see if things start working?

The GetContours code does not care about tags, so I don’t think that’s the issue.

The asset keeps freezing the editor once in a while when destroying streets… Luckily it didnt happen on device yet, but I’ve found the part of the code that gets stuck.
Maybe this gives a hint of what is happening:

Hi

That part of the code is just a separate worker threads that are waiting for work. It does not indicate that the system is stuck.
Can you see where the unity main thread is stuck?

How could I see where the unity main thread is stuck? all is frozen for 1-2 min until the Out of memory exception pops up.

How could we track down the reason of this? I’m out of ideas… could it be that the system doesn’t like to update the graph too many times in a small period of time?
I just update small portions using being bcBounds the collider of the street im adding/removing.

AstarPath.active.UpdateGraphs(bcBounds, 0.1f);

Any guidance on solving this would help a lot

PS: Until now I thought this was just happening on editor but today I confirmed it happens on device too.

[Exception] OutOfMemoryException: Out of memory
System.Collections.Generic.List`1[T].set_Capacity() at <695d1cc93cca45069c528c15c9fdd749>:0

System.Collections.Generic.List`1[T].EnsureCapacity() at <695d1cc93cca45069c528c15c9fdd749>:0

System.Collections.Generic.List`1[T].Add() at <695d1cc93cca45069c528c15c9fdd749>:0

GraphUtilities.GetContours() at /AstarPathfindingProject/Core/Misc/GraphUtilities.cs:220

RVONavmesh.AddGraphObstacles() at /AstarPathfindingProject/RVO/RVONavmesh.cs:97

RVONavmesh.OnLatePostScan() at /AstarPathfindingProject/RVO/RVONavmesh.cs:72

RVONavmesh.OnGraphsPostUpdate() at /AstarPathfindingProject/RVO/RVONavmesh.cs:46

GraphModifier.TriggerEvent() at /AstarPathfindingProject/Core/Misc/GraphModifier.cs:80

GraphUpdateProcessor.ProcessGraphUpdates() at /AstarPathfindingProject/Core/Misc/GraphUpdateProcessor.cs:186

WorkItemProcessor.ProcessWorkItems() at /AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:307

AstarPath.PerformBlockingActions() at /AstarPathfindingProject/Core/AstarPath.cs:881

AstarPath.Update() at /AstarPathfindingProject/Core/AstarPath.cs:864

Does this stack trace tell you something? I’m trying to find any hint to solve this please give me a hand to find the cause.

Hi

Which version of the package are you using?

I’m guessing you are not using the beta because the RVONavmesh component has been deprecated in the beta. I think the bug you are seeing has been fixed in the beta version, but in any case removing the RVONavmesh component should work around the issue.

I have 4.2.15
Is there any guide to upgrade?
EDIT: Upgrading to 4.3.46 through UPM

1 Like