How to clear out buffers stored in `task_local_storage`

Before, the buffer is inside my struct and those are reclaimed whenever objects are GC-ed.

If I used task_local_storage, the buffer would accumulate infinitely on the main task, should I use finalize() to clear out the task_local_storage()[key] manually? Or we don’t know the fianlizer will always be on the main task?

(the other tasks I don’t have to worry about because their task local storage will be cleared out when they get GC-ed)

Yeah finalizers can run on any task.

Nothing really great comes to mind. Weak refs might be an option, but they aren’t great.

One option is to provide an explicit clear function…

not the worst design I suppose…