question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory Leak due to Telemetry

See original GitHub issue

Category

  • Bug

Describe the bug

One of my teammates has been hunting a memory leak in our software for a few weeks now. Last night was the first night we saw zero increase in memory usage and it’s because we set the PnPCoreOptions.DisableTelemetry to false.

He had narrowed it down to Application Insights, and after finally getting a good profile from ANTS, saw that it all revolved around TelemetryManager and the TelemetryConfiguration in there.

I noticed in PnPContext.Dispose the comment:

// Note: flushing telemetry does not belong here since apps potentially can create/dispose a lot of contexts

And I get it. Since we’re sharing the TelemetryManager amongst the PnPContexts and PnPContextFactory, it’s not like any of those can dispose it without hurting others.

One suggestion my teammate had was to allow us to pass in a static TelemetryConfiguration so that it’s not instantiated every time.

Use Case

I realize we use PnP.Core a little different than most. We use it VERY dynamically and do not pre-register sites. We are a multi-tenant SaaS product, and we take it one step further: every long-running job (a la SharePoint Timer Job) is wrapped in its own Autofac.ILifetimeScope where we inject the current tenant. When the job is done, we dispose the scope and ideally, everything with it.

While I’m sure that the DI frameworks and GC should do most of the work, we have found that to not always be the case, so we try to be meticulous in our IDisposables.

Since PnPCoreContextFactory is registered as a transient, sure seems like we’re instantiating a LOT of TelemetryConfigurations, when we probably shouldn’t.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jansenbecommented, Jun 16, 2021

Thanks for raising this @DaleyKD , if this results in unneeded memory pressure then let’s see how it can be done different.

1reaction
jansenbecommented, Jun 16, 2021

@DaleyKD : Based upon my research it should, please let me know if you encounter issues

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak in application causing slowdown · Issue #3625
I'm seeing what appears to be memory leaks in the OTel libraries that are slowly bringing my app to a crawl. What is...
Read more >
Using Metrics and Traces to diagnose a memory leak
In this scenario, we will walk through a scenario demonstrating how to move from high-level metrics and traces to determine the cause of...
Read more >
Binaries memory leak with quantum and (open)telemetry
A Phoenix app I am working on is experiencing binaries related memory leak during Quantum triggered processing.
Read more >
C# Azure TelemetryClient will leak memory if not implemented ...
I noticed that my classic .net web application would leak memory after I implemented metrics for some background tasks.
Read more >
CSCvy31031 - Telemetry memory leaks on green infra library
Cisco Bug: CSCvy31031 - Telemetry memory leaks on green infra library. ... Symptom: IOS XE devices may see overall memory usage increasing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found