Wasteful memory allocations in PathFinder

Started by Razuhl, April 12, 2018, 12:36:43 AM

Previous topic - Next topic

Razuhl

The Verse.AI.PathFinder class is instanced for each map and each instance holds a variable calcGrid. This variable contains an entry for every cell on the map, containing a structure used in the pathfinding.

The data stored in the calcGrid is however independant from the map. By placing the sequences statusOpenValue and statusClosedValue and the calcGrid in a static context only one grid big enough for the largest map encountered is necessary instead of creating a seperate grid for each map.

A map with size 256x256 reserves slightly more than 1MB just for this.

Tynan

Definitely a useful observation; note taken. Thanks Raz.
Tynan Sylvester - @TynanSylvester - Tynan's Blog