Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heap Generation 2 and Large Object Heap climbs

I am not sure if I am posting to the right StackOverFlow forum but here goes.

I have a C# desktop app. It receives images from 4 analogue cameras and it tries to detect motion and if so it saves it.

When I leave the app running say over a 24hr cycle I notice the Private Working Set has climbed by almost 500% in Task manager.

Now, I know using Task Manager is not a good idea but it does give me an indication if something is wrong.

To that end I purchase dotMemory profiler from JetBrains.

I have used its tools to determine that the Heap Generation 2 increases a lot in size. Then to a lesser degree the Large Object Heap as well.

The latter is a surprise as the image size is 360x238 and the byte array size is always less than 20K.

So, my issues are:

Should I explicitly call GC.Collect(2) for instance? Should I be worried that my app is somehow responsible for this?

like image 562
Andrew Simpson Avatar asked Oct 17 '25 11:10

Andrew Simpson


1 Answers

Andrew, my recommendation is to take memory snapshot in dotMemory, than explore it to find what retains most of the memory. This video will help you. If you not sure about GC.Collect, you can just tap "Force GC" button it will collect all available garbage in your app.enter image description here

like image 177
Roman Belov Avatar answered Oct 21 '25 08:10

Roman Belov