How to simulate low memory for .net application?

Well, I need to debug the memory allocation problem. Over time, the application is exhausted. I need to simulate a low memory system for a .net window application as a way to more quickly reproduce a memory problem.

PS: My initial research suggests that a memory leak occurs when an application allocates unmanaged resources (managed by DX).

+4
source share
4 answers

Write another program that allocates all your system memory :)

Alternatively, debugging in a low memory virtual machine

+9
source
static volatile byte[] wasted; //volatile to avoid any compiler cleverness "saving" us! static void Main(string[] args) { wasted = new byte[1024 * 1024 * 1024];//waste a gig! } 

It would also be nice to run Application Verifier in your application.

+1
source

In addition, I would suggest that you use the .NET profiler so that you can check in which area of ​​your program allocates more memory.

0
source

If the application does not have enough memory accessing unmanaged resources, this could be a memory leak. Running the application in an environment with low memory directly will not help you diagnose the problem, it will happen faster.

You need to profile the memory usage of the application to determine how memory is allocated and find a leak. Conventional profiling tools will not help, because unmanaged code will not be profiled. You will need to create a memory monitoring application.

0
source

Source: https://habr.com/ru/post/1385771/


All Articles