5

Well, I have to debug a memory allocation issue. The application runs out of memory over time. I need to simulate low memory system for a .net window app, as a way to reproduce the out of memory issue more quickly.

PS: My initial investigation suggests that the memory leak is occurring while the application is allocating unmanaged resources (Managed DX).

Trainee4Life
  • 2,203
  • 2
  • 22
  • 38
  • Out of memory exceptions usually don't mean that you actually run out of physical memory, but that you run out of virtual memory address space. – svick Dec 11 '11 at 18:45

4 Answers4

9

Write another program that allocates all of your system's memory :)

Alternatively, debug in a VM with low memory

Christopher Neylan
  • 8,018
  • 3
  • 38
  • 51
2
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 could also be well worth running the Application Verifier on your app.

Jon Hanna
  • 110,372
  • 10
  • 146
  • 251
1

In addition, I'd suggest you to use a .NET profiler so you can check which area of your program is allocating more memory.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
1

If the application is running out of memory accessing unmanaged resources, that is likely to be a memory leak. Running the application in a low-memory environment won't directly help you diagnose the problem, it will just happen faster.

You need to profile the application's memory usage in order to determine how the memory is being allocated and find the leak. Normal profiling tools won't help because the unmanaged code won't be profiled. You'll have to get creative with a memory monitoring app.

Dave Swersky
  • 34,502
  • 9
  • 78
  • 118