Search code examples
c#memoryvirtual

How to release the VM / private bytes of a Desktop application in c#


I have desktop application developed in C#. The VM Size used by application is very high. I want to add watermark to a pdf file, which has more that 10,000 pages, 10776 pages to be exact, the VM size inscreases and some times the application freezes or it throws out of memory exception.

Is there a solution to release / decrease the VM size programatically in C#


Solution

  • Environment.FailFast :)

    In all seriousness though, a large VM size is not necessarily an indication of a memory problem. I always get confused when it comes to the various memory metrics but I believe that VM size is a measurement of the amount of used address space, not necessarily used physical memory.

    Here's another post on the topic: What does "VM Size" mean in the Windows Task Manager?

    If you suspect that you have a problem with memory usage in your application, you probably need to consider using a memory profiler to find the root cause (pun intended.) It's a little tricky to get used to at first but it's a valuable skill. You'd be surprised what kind of performance issues surface when you're profiling.