From 02c6354003a2b2a5a033969ff842d508171b622b Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 29 Jan 2023 18:08:40 +0200 Subject: [PATCH] Store pooled ManagedArray in thread-local storage --- Source/Engine/Engine/NativeInterop.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index 4d38125f8..9db15e112 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -287,10 +287,12 @@ namespace FlaxEngine /// private static class ManagedArrayPool { - private static List> pool = new List>(); + [ThreadStatic] private static List> pool; internal static ManagedArray Get() { + if (pool == null) + pool = new List>(); for (int i = 0; i < pool.Count; i++) { if (!pool[i].Item1)