# .NET Framework APM agent Memory leak

**URL:** <https://discuss.elastic.co/t/net-framework-apm-agent-memory-leak/245455>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [August 18, 2020, 3:11pm UTC](https://discuss.elastic.co/t/net-framework-apm-agent-memory-leak/245455 "2020-08-18T15:11:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![baronson](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@baronson](https://discuss.elastic.co/u/baronson)\
**Post date:** [August 18, 2020, 3:11pm UTC](https://discuss.elastic.co/t/net-framework-apm-agent-memory-leak/245455/1 "2020-08-18T15:11:54Z")

</div>

**Kibana version** : 7.8.0

**Elasticsearch version** : 7.8.0

**APM Server version** : 7.8.0

**APM Agent language and versions** :

- Elastic.Apm.AspNetFullFramework 1.6.1

- Elastic.Apm.EntityFramework6 1.6.1

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: Elastic Cloud

**Description of the problem including expected versus actual behavior.** : Memory leak occurs when [Asp.Net](http://Asp.Net) Full Framework and EF 6 agents are running. Memory for this server usually sits between 75% to 85% usage. With agent install the system slowly climbs to 100% memory usage and crashes. This is using the default settings for the agents.

 ![APM_Memory](https://us1.discourse-cdn.com/elastic/original/3X/c/0/c03f03e7ea11723facc373e425f5238ac2de8472.png)

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [August 18, 2020, 3:32pm UTC](https://discuss.elastic.co/t/net-framework-apm-agent-memory-leak/245455/2 "2020-08-18T15:32:15Z")

</div>

@baronson, I'll look deeper into this, couple of ideas:

- Can you try putting into the application and make sure this executes during app startup?

```auto
Activity.DefaultIdFormat = ActivityIdFormat.Hierarchical;
Activity.ForceDefaultIdFormat = true;

```

[This](https://github.com/elastic/apm-agent-dotnet/issues/867) is a related bug which was fixed - if executing that code fixes the issue then it's a leftover edge case and we'll need to do another iteration on it.

- Do you use the Public Agent API or is it just auto instrumentation?
- Any chance giving us a memory dump? And also an agent log on trace level where you let the app run until it collects couple of requests?

The 1. point would be worth trying first - that'd already give me some good hints.

Thanks,  
Greg

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 8, 2020, 11:32am UTC](https://discuss.elastic.co/t/net-framework-apm-agent-memory-leak/245455/3 "2020-09-08T11:32:27Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
