views:

184

answers:

5

I'm trying to reproduce a bug that seems to appear when a user is using up a bunch of RAM. What's the best way to either limit the available RAM the computer can use, or fill most of it up? I'd prefer to do this without physically removing memory and without running a bunch of arbitrary, memory-intensive programs (ie, Photoshop, Quake, etc).

+4  A: 

Use a virtual machine and set resource limits on it to emulate the conditions that you want.

VMWare is one of the leaders in this area and they have a free vmware player that lets you do this.

mythz
+3  A: 

Use either a job object or ulimit(1).

Ignacio Vazquez-Abrams
+4  A: 

I'm copying my answer from a similar question:

If you are testing a native/unmanaged/C++ application you can use AppVerifier and it's Low Resource Simulation setting which will use fault injection to simulate errors in memory allocations (among many other things). It's also really useful for finding a ton of other subtle problems that often lead to application crashes.

You can also use consume.exe, which is part of the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 Service Pack 1 to easily use a lot of memory, disk space, cpu time, the page file, or kernel pool and see how your application handles the lack of available resources. (Does it crash? How is the performance affected? etc.)

nick
+1 for *consume.exe*, i never knew about it. I don't think i'll tell my testers about it, they may go crazy with it and complain that what i write doesn't work well when there is only 16MB RAM and the CPU is going mental :)
slugster
A: 

Create a virtual machine and set the ram to what you need.

The one I use is Virtual Box from SUN.

http://www.virtualbox.org/

It is easy to set up.

Todd Moses
A: 

If you are developing in Java, you can set the memory limits for the JVM at startup.

Thilo