Memory leak, if thread never ends
quininer opened this issue · comments
quininer commented
We make thread hold Rc until the thread ends. but if thread never ends, then even if all ThreadLocal<T>
is released, then memory will not be released.
maybe we should make thread hold a weak reference.
quininer commented
We have two options to solve this problem,
- Release all memory when
ThreadLocal<T>
is dropped, but this means that destructor of thread A may be executed in thread B. This requiresSend
. - Mark it when
ThreadLocal<T>
is dropped, and other threads need to actively call clean function to check value to be released.
option 2 has great limitations, so I might choose option 1.