-
Notifications
You must be signed in to change notification settings - Fork 525
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
Issues with recursion #89
Comments
That looks bad. From what you're saying the first sample leaks memory and it should not leak — the expected behavior is for it to use a constant amount of heap memory. You shouldn't need to wrap the recursive call in a I haven't played with the samples yet. |
Note that the recursive call to loop (in both cases) is not in tail position due to the |
I have run this on the |
Note that this runs instantaneously with |
I think what a lot of this comes back to is the fact that |
For what is worth Monix's The Cats @djspiewak @tpolecat @mpilquist I would like to submit a PR with the But it might take some effort on my part, one or two days of work, so I need confirmation that it is something you're interested in, before committing to it. |
Actually I'll just go ahead and do it, because it's easier to show then tell. Cats's |
Sounds great @alexandru |
@alexandru I'm definitely interested in a better encoding. There are things I like about the one we have, but ultimately it's just a relatively naive optimization on top of |
Yep, I'd like to see a fix. It's unusable in current form. |
Great, I’m working on it.
--
Alexandru Nedelcu
alexn.org
|
Couldn't let it go for today 😀 So I pushed PR #90 — it might need more tests, waiting on code coverage report (couldn't get it to work locally today), but it definitely fixes this issue. |
I've added some benchmarking results in the PR and I'm happy to report dramatic differences 😀 |
Hi,
I discussed this issue with @tpolecat on gitter and he advised me to report it.
As I was looking at different ways of expressing an infinite (or very large) recursion I stumbled upon this snippet that produces strange result:
This works but takes a very long time and allocates several GB of memory (it becomes exponentially slower and slower so we can suspect that it allocates exponentially more and more memory at each iteration). You can entirely reclaim the memory after all so there is no leak.
Also using
IO.suspend
the iteration itself works perfectly, but in case of error the error is not reported as expected because of a StackOverflowError inAndThen.runLoop
.The text was updated successfully, but these errors were encountered: