C
C#14mo ago
Cracker

❔ 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
Cracker
CrackerOP14mo 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
mtreit14mo ago
30 MiB doesn't seem like that much How big is the memory dump?
Cracker
CrackerOP14mo 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
mtreit14mo ago
34 MiB is nothing. That's not a memory leak.
Cracker
CrackerOP14mo ago
How can I tell if its just too much request that cause System.OutOfMemoryException or memory leak ?
mtreit
mtreit14mo 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.
Cracker
CrackerOP14mo ago
that should be seen in dump file right
mtreit
mtreit14mo ago
Not necessarily
Cracker
CrackerOP14mo ago
how is that if application creates excessive objects that cause memory leak, it should appear in memory dump
mtreit
mtreit14mo 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.
Cracker
CrackerOP14mo 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
mtreit14mo 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.
Cracker
CrackerOP14mo ago
yeah thats right
Cracker
CrackerOP14mo ago
sorry for language
No description
Cracker
CrackerOP14mo 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
mtreit14mo ago
IIS harold
Cracker
CrackerOP14mo ago
response time 500ms
No description
mtreit
mtreit14mo 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.
Cracker
CrackerOP14mo ago
1.680.000 K process memory usage right before OutOfMemoryException will try with disable 32-bit on thistbh )
Cracker
CrackerOP14mo ago
this is max allocation I can catch, might not be memory leak, it behaves normal right after decrease excessive request
No description
Cracker
CrackerOP14mo ago
but process still allocation memory, which should be less than that, still at the peak size
No description
Cracker
CrackerOP14mo ago
second dump file after test, allocation remains, looks like not disposed
No description
Accord
Accord14mo 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.
Want results from more Discord servers?
Add your server