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.

High memory usage

See original GitHub issue

Describe the bug We have a service running on two nodes. After a load test I see a high rise of memory usage. I took a memory dump of both and see most of memory is consumed by

  • Task+ContingentProperties (about 23%)
  • Task<Object> (about 21%)
  • PooledTimer (about 19%)

If I look at Retained Size I see a usage of 84% on TimerPool (502 instances).

My application is reading and writing to Azure CosmosDB in a highly parallelized way (several Parallel.ForEachAsync).

To Reproduce Sorry, but I can’t reproduce this outside of the test environment.

Expected behavior Memory consumption is lower.

Actual behavior Server memory is eaten up somewhere.

Environment summary SDK Version: 3.35.2 (Microsoft.Azure.Cosmos) OS Version (e.g. Windows, Linux, MacOSX): Windows Server 2019 Datacenter

Additional context I guess this is memory is consumed by the connection pool for cosmos db. I have configured it as

MaxTcpConnectionsPerEndpoint = 1000, // Default: 65535
IdleTcpConnectionTimeout = TimeSpan.FromHours(2), // Default: unlimited

to limit the memory usage.

Sorry if this is the wrong place for this question but I don’t know where to ask elsewhere.

Issue Analytics

  • State:open
  • Created a month ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ealsurcommented, Aug 10, 2023

On the server there are about 333 instances of StoreClient/DocumentClient

This is the problem, you have 333 client instances. Each client instance has an independent connection pool, that is why it’s critical to follow the Singleton pattern as our guidelines say. Connections are not shared across client instances.

The large size in PooledTimer objects is due probably to the large size in client instances.

Where are these instances created? Really only you can tell.

0reactions
ealsurcommented, Aug 18, 2023

MaxRetryWaitTimeOnRateLimitedRequests = TimeSpan.FromHours(2), RequestTimeout = TimeSpan.FromHours(2),

MaxRetryWaitTimeOnRateLimitedRequests has nothing to do, it is the setting to retry on 429s. 2 Hours for RequestTimeout is really pointless. RequestTimeout is meant to govern the max latency a TCP request can have on the wire. Normal values go from 1-60 seconds. This is supposed to mean “My application will only consider acceptable waiting for a network request up to X time, after which, consider it a timeout”, I doubt your application can wait 2 hours for a single network request? If so, then there are no users waiting for that response? https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/troubleshoot-dotnet-sdk-request-timeout?tabs=cpu-new#customize-the-timeout-on-the-azure-cosmos-db-net-sdk

The run on a Azure VM Standard_B2ms together with other services. They are implemented as a Azure Service Fabric Stateless Service.

Standard_B2ms has 2 cores. Based on https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/best-practice-dotnet, you probably should be using Gateway mode.

is there any possibility to get the source and create pull requests for TimerPool and PooledTimer?

Source is: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/msdata/direct/Microsoft.Azure.Cosmos/src/direct/PooledTimer.cs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix High RAM Memory Usage Issue on Windows 11/10 ...
High Memory Usage is a state where Windows computers' RAM, ROM, or Cache usage grows to an extremely high level. Windows 10 high...
Read more >
High memory usage. How to fix them
1) See fixes for high RAM usage: · 2) Optimize Virtual Memory: · 3) Type Resource in Search box, open Resource Monitor as...
Read more >
Windows 10 high memory usage (unknown reason)
You have a memory leak caused by a driver. Look at the high value of nonpaged kernel memory. In your case this is...
Read more >
[SOLVED] - Extremely high memory usage for no reason
in rammap, go to the File details tab and sort the size by biggest by clicking on the header. Drivers do show in...
Read more >
Top 12 Fixes: High RAM/Memory Usage on Windows 11/10
1. Close Excessive Programs 2. Reduce the Number of Startup Programs 3. Check to See if Superfetch Is Disabled 4. Select Best Performance...
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