-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application insights increases application memory usage #1429
Comments
it would really help if you could tell the version and flavor of AppInsights SDK you have (nuget packages names and versions) and how you configured it. |
|
you should not use both of them, please remove Web SDK. |
Thank you for you fast response! I will republish and let you know how it worked. |
Below is a picture of memory use with packages as follows:
I have marked the milestones: the first vertical line is where I disabled the AI and the second is where I published with only the AspNetCore SDK. UPDATE: Currently is above 550 MB |
@alexiordan , Application Insights SDK creates a lot of managed object per each telemetry item tracked (ConcurrentDictionaries to track properties, URIs and so on..) in addition to the telemetry item itself. Therefore, AI is known to pollute GC heap with unused objects that should be collected in due time. In combination with Server Garbage Collection it leads to severe memory gain as Server-oriented GC allows memory to grow significantly before it kicks in to keep it at server acceptable level. If memory is a scarse resource on the machine, setting Server GC to false sounds like a good idea. I'd expect with AI SDK and Server GC false that memory would still grow higher than without AI but should become stable / contained on a certain level due to more frequent GC (a.k.a. Desktop GC). Another workaround to try is to invoke GC from code periodically, but that's significantly less appealing. |
Thank you @Dmitry-Matveev , for your reply. Finally there is an explanation for this behavior. Would you mind take a look at the following 3 questions.
As can be seen from the picture below - latest screenshot of app with AI enabled - memory seems to be kept below ~1.2 GB
I ask because I want to have AI enabled, but I also run multiple apps on the same App Service Plan (S2): 3.5 GB RAM.
|
@Dmitry-Matveev can you respond to the questions above? |
Yes. Server GC will allow memory to grow significantly cleaning up rarely. Desktop GC will allow memory to grow to an extent while cleaning it up more often.
Can't really say as it depends on what Server GC "thinks" the right time to kick off is. The picture looks like 1.2GB is some kind of threshold for GC (e.g. 33% of avialable RAM) where it kicks off and bounces away to the state with no stale AI objects.
I would expect GC may allow memory to grow further. If the assumption about 33% RAM is correct, I'd say GC will kick in at 2.5 GB in that case. |
About 2 month ago I scaled-up to P2V2 (7GB of RAM) to see the behavior. Are there documented anywhere those percentages? |
@alexiordan If you take a memory dump and analyze, you will probably notice that the majority of the committed memory is unused overhead, pages of memory that runtime is holding for future use instead. |
Thank you, @israellot ! |
Have the same issue #2140 |
This issue is stale because it has been open 300 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
With Application Insights enabled my application uses up to 1.2 GB of RAM. With Application Insights disabled, the application uses around 200 MB. Please see the picture below.
Why?
It wouldn't be a problem, but I am get warnings about the used memory raising above the 80% threshold and that I may encounter errors because of that.
I have also other applications running in the same App Service Plan (S2): 3.5 GB RAM.
The application is a .Net Core Asp.Net AppService using SignalRService. It is configured with
<ServerGarbageCollection>false</ServerGarbageCollection>
(see:dotnet/aspnetcore#1976 (comment) )
The difference between the right and the left part of the red bar in the image are only the following 2 lines of code.
where
NoSignalRRequestFilter
class is as follows:Would someone, please, help me figure this out?
The text was updated successfully, but these errors were encountered: