• /
  • EnglishEspañolFrançais日本語한국어Português
  • 로그인지금 시작하기

High AppDomain.GetData() lock contention or increased native memory

|View as Markdown (English)

Problem

The .NET agent caches the method information it needs to call the agent from instrumented methods. Since version 10.54.0, the agent uses this cache for both .NET Framework and .NET or .NET Core applications. Before version 10.54.0, the agent used it only for .NET Framework applications.

The cache can cause these symptoms:

  • .NET Framework: A high-throughput application shows high thread contention. Process dumps and stack traces show many threads blocked in calls to AppDomain.GetData().
  • .NET or .NET Core, agent versions 10.54.0 through 10.56.0: The application uses more native memory than it did with agent version 10.53.x. The increase grows with the number of assemblies the application loads.

Cause

The .NET agent needs method signature information to instrument methods. To avoid a reflection call each time an instrumented method runs, the agent caches this information. The cache uses more memory to save CPU time. In our testing, applications had higher maximum throughput with the cache enabled.

On .NET Framework, the agent stores part of this cache in AppDomain storage. Calls to AppDomain.GetData() take a global lock, which can cause thread contention in some high-throughput applications.

On .NET and .NET Core, agent versions 10.54.0 through 10.56.0 add references to agent helper methods to every module the application loads, including modules that have no instrumented methods. The runtime keeps a copy of the metadata of each changed module in native memory.

Before you change agent settings

The symptoms above can have many causes. Contact New Relic support with a thread dump or memory measurements before you change agent settings. Support can confirm whether the agent's method cache is the cause.

Solution

If you use .NET agent 10.54.0 through 10.56.0 on .NET or .NET Core and see the native memory increase described above, update the agent to a version newer than 10.56.0. In those versions, the agent adds these references only to System.Private.CoreLib and to modules that have instrumented methods.

If support confirms that the agent's method cache is the cause and you can't update the agent, you can disable the cache with this environment variable:

NEW_RELIC_DISABLE_APPDOMAIN_CACHING=true

This setting is available in .NET agent version 9.7 and higher, and it applies to .NET Framework, .NET, and .NET Core applications. You can leave it enabled long-term.

주의

This setting doesn't reduce managed heap usage, and it doesn't fix slow requests or high CPU. With the cache disabled, the agent uses reflection each time an instrumented method runs, which increases agent overhead. In our testing, applications had lower maximum throughput with the cache disabled.

Copyright © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.