Skip to content

Could Activity.Events cause memory exhaustion in long running activities? #42347

@JamesNK

Description

@JamesNK

Activity.Events is new in .NET 5. Is there any concern that a long running activity, with many events, could create a memory leak cause memory exhaustion in an app?

The specific scenario I'm thinking of is a long running gRPC streaming call. There is an activity on the client and server that lasts for the duration of the call. In OpenTelemetry each sent and received message is an event. See https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/rpc.md#events. Message activities would be added to the call activity as events.

If a call sends and receives hundreds of thousands of messages over the lifetime of a call, and each time adds a new ActivityEvent + attributes to the current activity, I believe those events will stay in-memory until the call is complete. Memory usage over the lifetime of a long running call will continuously increase.

Is my theory correct? What is the guidance here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Diagnostics.TracingquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions