0

I have a simple sample that has three buttons. Investigating the sample with the diagnostic tool in the Visual Studio shows that, the process memory and the memory snapshot results are not equal.

Find the below screenshots with captions to understand the scenario and its findings. enter image description here

Screenshot 1: Started the application enter image description here

Screenshot 2: Loading a PDF file as a file stream, by clicking the OpenFile button. Then copying it to a new memory stream. The memory shoots here

enter image description here

Screenshot 4: The process memory is reduced on clicking the GC.Collect(), and again the memory snapshot is taken NOTE: I cannot keep calling the GC.Collect() to reduce the memory as it affects the performance of my application.

My Questions are: :

  1. Why there is a difference between the process memory and the memory snapshot?
  2. Any solution is there to equalize them?
  3. What could be your recommendation to handle such situation?

Steps To Reproduce

  1. Extract the below sample
  2. Run the sample
  3. Open the Task manager
  4. Check the Process Memory and take a Memory snapshot
  5. Click the OpenFile button check the Process Memory and take a Memory snapshot
  6. Click the DisposeFile button check the Process Memory and take a Memory snapshot
  7. The process memory size keep on increasing.

Sample project :

https://drive.google.com/file/d/1Kdk-Kyp3G1red-8Kl56SptEzx_e1_wU_/view?usp=sharing

.NET Version - dotnet 3.1, 6.0, 7.0

Kamesh
  • 61
  • 3

0 Answers0