Why does tsgo use so much memory?
The article discusses the high memory usage of tsgo when running on large Typescript projects. It explains that each thread creates its own type checker, leading to duplicated memory allocation. Additionally, the article highlights the significant memory consumption by AST nodes and the type checker itself.
- ▪Tsgo can use gigabytes of memory when processing large Typescript projects due to multi-threading.
- ▪Each type checker created per thread maintains its own state, resulting in redundant memory allocation.
- ▪The type checker consumes significantly less memory when run in single-threaded mode, indicating overhead from multi-threading.
Opening excerpt (first ~120 words) tap to expand
5/27/2026 Why does tsgo use so much memory? If you run tsgo on decently sized Typescript project, it’s not uncommon to see it using gigabytes of memory. Why is that? The short answer is: when multi-threading, tsgo makes a type checker per thread each type checker has its own state (types, symbols, etc.) this state is not shared as synchronizing it between threads is costly so each type checker often allocates duplicate, redundant memory in addition, allocated types are never freed It’s not uncommon for Typescript projects to have: several thousand Typescript files libraries like Zod, tRPC, Drizzle which result in many, many type instantiations recursive generic types which product a lot of transient types which are never freed When running tsgo on a large Typescript project, these type…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Zackoverflow.