Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
(#1363) Fix memory leak in ReadEventsInternalAsync for subscriptions #1365
ReadEventsInternalAsync and ReadEventsCallbackAsync called each other recursively. This resulted in stackoverflowexception when subscribing to a very large stream and a lot of memory pressure.
Main fix is to create a do..while in ReadEventsInternalAsync to facilitate continuing with the next slice if not done. This in stead of the recursive call.
As a side effect a couple of parameters could be dropped because they were only passed between the functions but not really used.
No problem. I looked at the changes and fixed some tabs vs spaces. But I'm afraid this is as good as I can get it. There are some indentation differences that are caused by the do..while loop and the changes in the 'if' structure. So most of the formatting changes that are left are intentional.
I think the best way to review the change is to look at the version before and the version after and reason about both behaviours. Before it was a mutual recursive function, now it is a do..while loop. It does the same, but in a different way. But that change in behaviour doesn't show well in a text diff.
If you have any suggestions how to further clarify the changes i'm happy to give it a shot.