Forum Navigation
GC, Fibers, oh my
Posted: 03/22/07 04:23:13I am using fibers and coroutines for async network servers. They leak badly. As we know, if the dtor is not run on a Fiber then its stack will not be freed. I have read the documentation on digitamars.com about instance allocation and destructors. Apparently, class instances created with new are allocated on the stack and the dtor will never run. I use new so I have never seen the dtor run on a Fiber unless I use a delete expression. dm.com gives a list of ways to create instances on the stack but none on the heap. How is it done? I tried hacking the Fiber class to automatically free their stack by adding a freeStack() after termination/switchOut but that didn't work. What do I do?
Also, it seems to me that Fiber.getThis() is unnecessarily private. To implement a future I need the current Fiber, so I can switch to it when the results are ready.
AtDhVaAnNkCsE