Surprisingly high Memory Allocation - Simple use case (URP)
Hi there, I set it as a bug though it may not be one (however, that would mean we can't use Shapes for what we intended to unfortunately : ( ).
I just wrote a simple script which draws many discs and it works perfectly fine. My class is inheriting from Immediate Mode Shape Drawer and I'm simply calling Draw.Disc in a loop inside a using block for Draw.Command as recommended in the documentation.
I had a look at the profiler to see the impact of doing that before working more on making cool things with Shapes but I noticed that for around 100 discs, it allocates around 21kb per frame, and it linearly increases the more calls to Draw.Disc I make.
I don't know if it only happens in URP but I wouldn't be surprised since the GC.Alloc calls are all made in RenderPipelineManager::DoRenderLoop_Internal(). Of course I quickly tested disabling my script using Shapes to make sure it comes from it, and all allocation disappear if I don't run my Shapes stuff : (
I also tested in a standalone build and I have the same results.
Any idea if it could be improved or if it's due to the design and will stay that way, please?
Edit: Additional information, if I disable the ShapesRendererFeature in the renderer settings for URP, it doesn't draw the shapes anymore (as expected), but it still allocate the same amount of memory.
Thanks,
Clem
this has now been fixed in 3.1.0 across all render pipelines!
note that Draw.Text will still allocate for, silly reasons, that I can hopefully fix in the future!