❔ Memory Leak Dump Analysis Local Load Test

I am using Roslyn Scripting API to evaluate expressions in my web project, there is excessive creation of roslyn script and compilation which end up memory leak. This was expected I will try better approach but I am practicing dump analysis on this one. Those are the results I load test and take dump from IIS worker. Those results indicate memory leak caused by excessive use of Microsoft.CodeAnalysis.CSharp.CSharpCompilation am I right ?
No description
23 Replies
atakancracker
atakancracker8mo ago
After a while, when almost all memory is in use, I started take responses as System.OutOfMemoryException: Insufficient memory to continue the execution of the program. at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb) at Dump file created with dotnet-gcdump collect -p 24480 -o D:\dmptest3 -v when memory use is at peak Since I am testing only the use of CSharpCompilation, its actually normal to see it at peak. How to know if its actual memory leak or just too much request ?
mtreit
mtreit8mo ago
30 MiB doesn't seem like that much How big is the memory dump?
atakancracker
atakancracker8mo ago
file itself 34MB, I am trying another run we have performance test environment with server machines, this one I am running locally to pratice before
mtreit
mtreit8mo ago
34 MiB is nothing. That's not a memory leak.
atakancracker
atakancracker8mo ago
How can I tell if its just too much request that cause System.OutOfMemoryException or memory leak ?
mtreit
mtreit8mo ago
If you are getting OutOfMemory exception but are using only megabytes (not gigabytes) of memory then something else is going on. For instance, creating more than the maximum number of elements in an array.
atakancracker
atakancracker8mo ago
that should be seen in dump file right
mtreit
mtreit8mo ago
Not necessarily
atakancracker
atakancracker8mo ago
how is that if application creates excessive objects that cause memory leak, it should appear in memory dump
mtreit
mtreit8mo ago
Consider this program:
var x = new int[int.MaxValue];
var x = new int[int.MaxValue];
This throws OutOfMemoryException but doesn't actually allocate anything that would show up in a memory dump.
atakancracker
atakancracker8mo ago
oh okay I see high memory usage not always indicates memory leak then, there is excessive request coming and application is just using all memory avaliable after a while usage decrease and starts responding requests back
mtreit
mtreit8mo ago
From what you've shown, there is no indication you are even seeing high memory usage. What's the peak memory usage of the process? Because the memory dump is only 300 MiB Which is nothing.
atakancracker
atakancracker8mo ago
yeah thats right
atakancracker
atakancracker8mo ago
sorry for language
No description
atakancracker
atakancracker8mo ago
this one is after load test not serving requests I will share one when I start load testing (load test is just multiple http requests)
mtreit
mtreit8mo ago
IIS harold
atakancracker
atakancracker8mo ago
response time 500ms
No description
mtreit
mtreit8mo ago
Looks like you are running 32-bit (x86) instead of 64-bit (x64), you should try changing that if you are seeing OutOfMemory issues.
atakancracker
atakancracker8mo ago
1.680.000 K process memory usage right before OutOfMemoryException will try with disable 32-bit on thistbh )
atakancracker
atakancracker8mo ago
this is max allocation I can catch, might not be memory leak, it behaves normal right after decrease excessive request
No description
atakancracker
atakancracker8mo ago
but process still allocation memory, which should be less than that, still at the peak size
No description
atakancracker
atakancracker8mo ago
second dump file after test, allocation remains, looks like not disposed
No description
Accord
Accord8mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.