fastjson2 icon indicating copy to clipboard operation
fastjson2 copied to clipboard

[FEATURE] ThreadLocal handling with Virtual Threads (JDK21)

Open zekronium opened this issue 5 months ago • 9 comments

请描述您的需求或者改进建议

The project heavily relies on ThreadLocal objects, which can cause explosive memory growth with Virtual Threads. In theory, ThreadLocals have relatively no effect with Virtual Threads since its encouraged to create many and short lived threads, which would wipe the Thread Local objects. Also, there can exist millions of virtual threads, where ThreadLocal also can become a problem.

请描述你建议的实现方案

Utilise a different mechanism of recycling such objects. Currently Jackson has created a virtual thread friendly recycler.

zekronium avatar Mar 12 '24 22:03 zekronium