views:

451

answers:

5

OS: Windows XP

Does anyone know of tools (preferably free) to limit memory available and also other windows resources (handles etc.)? I want to test an app with low memory to make sure it behaves properly and if there are already tools to do this sort of thing, I'd rather not write my own.

By the way, I did look for other Q & A threads for this and didn't find any. If this is a dupe, I apologize. Just let me know and I'll close this up.

+6  A: 

You can use boot parameters to Linux (grub.conf or lilo.conf) and Windows (boot.ini) to adjust the memory size.

On Linux, 'mem=128' in the kernel append line will limit to 128MB.

On Windows, "/MAXMEM=" in boot.ini. (Reference: Boot INI Options Reference)

EmmEff
That's a good answer EmmEff but I was hoping for something to allow me to dynamically control how much memory is available at runtime--make it easier to test with low (enough memory but barely enough) and exhausted (too little memory) conditions.
Onorio Catenacci
I used to do Windows file system driver development and there was a Microsoft tool for randomly failing memory allocation calls but I do not know of anything for user-space applications.
EmmEff
+1  A: 

You can edit boot.ini with the maxmem option:

http://support.microsoft.com/default.aspx?scid=kb;en-us;833721

Kris Kumler
+6  A: 

If you want to test a PC with low physical memory you can use a VM and assign it as little (or as much, if available on the host machine) RAM as you'd like.

Giovanni Galbo
I've seen a few problems that were only reproducible on VM's. I tend to favor a non-VM solution first but this is a good idea regardless.
Onorio Catenacci
@OnorioEven if the problems are only reproducible in VM's, it seems to be where the market is heading - even for home users..so testing for those kinds of bugs is probably still a good idea.
Giovanni Galbo
+2  A: 

You could use the Microsoft Application Verifier tool: http://technet.microsoft.com/en-us/library/bb457063.aspx

This will allow you to simulate low resources as well as many other issues. YMMV with using non-MS heaps, etc.

Kris Kumler
Great link. Thanks Kris.
Onorio Catenacci
+1  A: 

Reduce the paging memory to zero (Requires a restart). Then the application is restricted to only the physical memory. Helps the cause as paging file default size is 1.5gb in most cases. Trying to throttle the memory for an application will be frustrating with such a big page file.

rvanchis