Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I limit RAM to test low memory situations?

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).

like image 667
Newtang Avatar asked Feb 18 '10 01:02

Newtang


People also ask

What limitations does RAM have?

The speed of your processor and the bus speed of the computer motherboard are the limiting factors on the speed of RAM installed in your computer. RAM upgrades are limited by the capability of the computer and the availability of expansion slots for adding RAM.

How do I know if I use too much RAM?

Or, right-click the Taskbar and select Task Manager. Select the Performance tab and click Memory in the left panel. The Memory window lets you see your current RAM usage, check RAM speed, and view other memory hardware specifications. Open the Processes tab to see which tasks are consuming the most RAM.


4 Answers

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.

like image 63
mythz Avatar answered Sep 28 '22 06:09

mythz


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.)

like image 21
nick Avatar answered Sep 24 '22 06:09

nick


Use either a job object or ulimit(1).

like image 22
Ignacio Vazquez-Abrams Avatar answered Sep 28 '22 06:09

Ignacio Vazquez-Abrams


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.

like image 20
Todd Moses Avatar answered Sep 27 '22 06:09

Todd Moses