Why Does Unity Profiler Show Dozens of #0 Threads Under Scripting Threads When Using a Thread Pool?
I have a question regarding thread pools. Our project uses a thread pool, and when profiling in Unity Profiler, I can see dozens of threads labeled as under Scripting Threads . Is this normal behavior, or could it indicate a potential issue with our thread pool implementation?
This is not normal and should be investigated as soon as possible. When Unity Profiler shows a large number of Scripting Threads named , it usually indicates one or more of the following situations: ✅ Threads are not properly named or registered Unity does not automatically assign meaningful names to threads created through . As a result, the Profiler cannot identify their purpose and typically displays them as or as unnamed threads with numeric identifiers . ⚠️ Potential thread leak If the thread pool retains a large number of idle threads over time—particularly in Unity 2019–2022 projects—it may be caused by: Improper use of Asynchronous tasks that never complete or are not properly released Long blocking operations executed via Excessive thread pool scheduling that causes thread accumulation ❌ Non Unity managed threads appearing in the Profiler Threads displayed as generally have not been registered through Unity's profiling APIs such as . This means they are not actively tracked, making it difficult to identify their execution costs or trace their activity in the Timeline view. Recommended Actions 🔍 Review thread usage patterns Check for excessive use of or . For high frequency asynchronous workloads, consider using the Unity Job System or asynchronous solutions based on where appropriate. 🔍 Verify custom thread lifecycle management Ensure that any threads created via are properly managed. If is used, make sure the corresponding cleanup logic is executed correctly to avoid lingering profiling entries and resource leaks. 🔍 Capture thread creation call stacks Enable Call Stacks and Deep Profiling in the Unity Editor. Focus on frames with high CPU usage or excessive GC allocations. Identify the call stacks responsible for creating or scheduling threads. 🔍 Monitor thread count over time Use tools such as GameOptim GOT Online 's Mono and Threading analysis modules to monitor thread count trends and thread lifetimes. Verify whether the number of active threads remains stable or continuously increases during long play sessions. Important Note Unity does not recommend using the .NET ThreadPool as the primary mechanism for scheduling large numbers of short lived tasks. For performance critical and highly parallel workloads, the preferred solution is the Unity Job System , which offers better cross platform scalability, tighter engine integration, and full visibility within the Profiler.