-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak on choice operation of 'get' and 'sleep' #109
Comments
This is because the "block" function of Eventually that thunk gets scheduled and removed from the run queue, but that might take too long and cause the memory leak we're seeing. In the example above, changing from It seems to me that there needs to be a way to evacuate those |
Fixes wingo#109. Previously, an operation like: (choice-operation (sleep-operation 1234) (get-operation channel)) would accumulate timer wheel entries every time the ‘get’ operation wins over the ‘sleep’ operation, potentially leading to unbounded memory usage (each ‘sleep’ timer and its associated continuation would remain on the wheel for 1234 seconds in this case). This commit fixes it by removing the timer wheel entry as soon as the timer operation is canceled. * fibers/timers.scm (timer-operation)[wheel-entry]: New variable. Set it in block function. Add cancel function. * fibers/scheduler.scm (scheduler-timers): Export. * tests/cancel-timer.scm: New file. * Makefile.am (TESTS): Add it.
(Assigning the ... assignment based on what's happening) |
This is what the unique-to-Concurrent ML basic combinator See #97 and Reppy, Concurrent Programming in ML § 6.5. |
Fixes wingo#109. Previously, an operation like: (choice-operation (sleep-operation 1234) (get-operation channel)) would accumulate timer wheel entries every time the ‘get’ operation wins over the ‘sleep’ operation, potentially leading to unbounded memory usage (each ‘sleep’ timer and its associated continuation would remain on the wheel for 1234 seconds in this case). This commit fixes it by removing the timer wheel entry as soon as the timer operation is canceled. * fibers/timers.scm (timer-operation)[wheel-entry]: New variable. Set it in block function. Use ‘make-timer-operation/internal’ and add cancel function. * fibers/scheduler.scm (scheduler-timers): Export. * tests/cancel-timer.scm: New file. * Makefile.am (TESTS): Add it.
Fixes wingo#109. Previously, an operation like: (choice-operation (sleep-operation 1234) (get-operation channel)) would accumulate timer wheel entries every time the ‘get’ operation wins over the ‘sleep’ operation, potentially leading to unbounded memory usage (each ‘sleep’ timer and its associated continuation would remain on the wheel for 1234 seconds in this case). This commit fixes it by removing the timer wheel entry as soon as the timer operation is canceled. * fibers/timers.scm (timer-operation)[wheel-entry]: New variable. Set it in block function. Use ‘make-timer-operation/internal’ and add cancel function. * fibers/scheduler.scm (scheduler-timers): Export. * tests/cancel-timer.scm: New file. * Makefile.am (TESTS): Add it.
Fixes #109. Previously, an operation like: (choice-operation (sleep-operation 1234) (get-operation channel)) would accumulate timer wheel entries every time the ‘get’ operation wins over the ‘sleep’ operation, potentially leading to unbounded memory usage (each ‘sleep’ timer and its associated continuation would remain on the wheel for 1234 seconds in this case). This commit fixes it by removing the timer wheel entry as soon as the timer operation is canceled. * fibers/timers.scm (timer-operation)[wheel-entry]: New variable. Set it in block function. Use ‘make-timer-operation/internal’ and add cancel function. * fibers/scheduler.scm (scheduler-timers): Export. * tests/cancel-timer.scm: New file. * Makefile.am (TESTS): Add it.
The code below exhibits a memory leak with Fibers 1.3.1:
(The
heap-profiler.scm
file comes from here.)A typical run looks like this:
This suggests delimited continuations are being accumuated somewhere. It's all fine when commenting out the sleep operation.
The text was updated successfully, but these errors were encountered: