C# SubscribeToStreamFrom ever growing memory consumption and ending in stackoverflow exception


I’m subscribing to a very large stream (tens of millions of events) with SubscribeToStreamFrom. It seems to be ever growing in memory consumption

When I just read all events without processing

var es = EventStoreConnectionFactory.CreateConnection();
es.SubscribeToStreamFrom("$ce-qbox", 0, CatchUpSubscriptionSettings.Default, (s, e) =>



I see the following pattern in dottrace:

After a while the process crashes with a stackoverflowexception.

If I where to gues I’d say it’s somewhere around the following method in EventStoreCatchUpSubscription.cs

private async Task ReadEventsCallbackAsync(StreamEventsSlice slice, IEventStoreConnection connection, bool resolveLinkTos,
UserCredentials userCredentials, long? lastCommitPosition, long? lastEventNumber)
if (!(await ProcessEventsAsync(lastEventNumber, slice).ConfigureAwait(false)) && !ShouldStop)
await ReadEventsInternalAsync(connection, resolveLinkTos, userCredentials, lastCommitPosition, lastEventNumber).ConfigureAwait(false);
if (Verbose)


I think that as long it is processing the following happens

ReadEventsInternalAsync calls ReadEventsCallbackAsync calls ReadEventsInternalAsync calls ReadEventsCallbackAsync calls ReadEventsInternalAsync calls …

Does anyone have an idea how this can be fixed?

kind regards,

Arno den Uijl

Created issue https://github.com/EventStore/EventStore/issues/1363 and working on a fix.