gizmos
gizmos copied to clipboard
GC Alloc
Anyway to reduce or eliminate the memory allocation being created?
I'm using your gizmos to display hitboxes. It works really well!
i can try but i cant guarantee ill do it :p, if you find a solution to the root cause i can review the pr with you (theres likely areas that could be improved with how memory is used)
In the draw method
public static void Draw<T>(Color? color, bool dashed, params object[] args) where T : Drawer
the only spot that seems to allocate memory each time the method is called is this
Vector3[] array = new Vector3[points]; // Allocates memory each time.
We could look into using lists at the class level to solve this but, it seems like most of your code base uses arrays so it would require a bit of work to switch the arrays over to lists.
i could see it becoming an array rented from ArrayPool<Vector3>.Shared
and then returned after being used/consumed after drawing, trying to figure out why it wasnt like that in the beginning though lol
Yeah ArrayPool<Vector3>.Shared
sounds promising.
I've never actually knew that class existed until now.
The changes I tried making to avoid memory allocation ended up breaking the code completely.