4

Ok, so here's the problem. In our production environment (ASP.Net) our servers have a massive amount of memory as well as a massive number of users / sessions. My computer has 8 gigs, and I'm the only user. In production, we're (rarely) getting a System.OutOfMemoryException.

With that background information, here is the question: is it possible to make the CLR think I only have a gig of memory or less? IIRC, there's a command-line option to do this for Java.

Another option is to make some really big objects to fill up memory to simulate low memory conditions. But that requires modifying the assemblies and the huge objects might be cached to disk.

Recommendations? Or other options?

2 Answers2

4

One way to simulate a lower-memory/resource system is to create a system virtual machine and allocate the specific amount of memory you want it to have. Both VMWare and MS Virtual Machines have this feature.

Besides a simulation of a lower-resource machine VMs are also a great way to manage your test environments.

Paul Sasik
  • 79,492
  • 20
  • 149
  • 189
  • This is an awesome idea. In fact I already have a VirtualBox instance running! I just never considered the possibility. You win! –  Dec 03 '10 at 00:19
  • This seems like a clunky .NET solution for replacing a simple JVM argument. Yes the OS will handle the low-level processing of virtual memory, but what about when we want more granular control over which apps get priority to memory. Yes each apps gets the same virtual address space but we may want to limit how much memory app A consumes so the OS has plenty available for app B. – Kelly S. French Oct 11 '11 at 15:40
  • @Kelly French: My answer has nothing to do with .NET or Java. It merely suggests using a virtual machine (not the Java virtual machine) to create an environment where an OS with lower memory resources can be tested. The answer is not specific to any programming language, framework or even operating system. When I mention virtual machine, I mean this: http://en.wikipedia.org/wiki/Virtual_machine#System_virtual_machines – Paul Sasik Oct 11 '11 at 17:26
  • @Paul Sasik - My comment wasn't directed at you, more a general observation on the design decisions of .NET that makes it hard to arbitrarily control memory usage. I thought your solution was clever. – Kelly S. French Oct 11 '11 at 17:53
1

Whether or not your program recieves an OutOfMemoryException is independent of how much RAM is on your machine. OutOfMemoryException means the process has run out of virtual memory which is the same for every process independent of physical RAM

There are a couple of items which can affect the amount of virtual memory in a process

  • 32 vs 64 bit process
  • Switches like /LargeAddressAware (Documentation)

Best guess is the server is a 64 bit process while the client machine is 32

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454