Running my application in simulated low memory, slow processor environment

I want to emphasize - testing my application this way because it seems to fail in some very old client machines.

At first I read a little about QEmu and thought about hardware emulation, but it seems like a long shot. I asked superuser but did not get many reviews (yet).

So, I appeal to you guys ... How do you conduct such testing?

+7
source share
9 answers

I'm not sure if the processor is slowing down, but if you use a virtual machine like VMWare, you can control how much RAM is actually used. I run it on MBP at home with 8 GB, and my WinXP VM is limited to 1.5 GB.

EDIT . I just checked my version of VMWare, and I can control the number of cores that it can use. This is definitely not the same as a slow processor, but it may highlight some problems for you.

Since it is not entirely clear that your application is failing due to old hardware or an old OS, the VM client should allow you to test different versions of the OS fairly quickly. This helped me a few years ago when I tried to get the .Net 2.0 application to work on Win98 (this can be done, although I don’t remember how I got it working ...).

+7
source

Virtual Box is a free virtual machine similar to VMWare. It is also able to reduce available memory. It may limit the number of processors available, but not how fast these processors are.

+3
source

Try cpulimit , most distributions include (Ubuntu) http://www.digipedia.pl/man/doc/view/cpulimit.1

+2
source

If you want to reduce the speed of your processor, you can easily do this by changing the fork bomb program

int main(){ int x=0; int limit = 10 while( x < limit ){ int pid = fork(); if( pid == 0 ) while( 1 ){} else x++; } 

}

This will slow down your computer pretty quickly; you can change the limit variable to a larger number. I must warn you, although this can be dangerous, because if you make a mistake, you can unlock your system, leaving it useless if you do not restart it. Read this first if you don't understand what this code will do.

+1
source

On POSIX (Unix) systems, you can apply execution restrictions to processes (that is, to program execution). The system call for this is called setrlimit() , and most shells allow you to use ulimit built-in to install them from the command line (simple POSIX ulimit not very useful). Using them, you can run a program with low restrictions to simulate a smaller computer.

POSIX systems also provide a nice command to run a program with a lower CPU priority, which can simulate a slower CPU if you also provide another processor intensive program at the same time.

+1
source

I think it is very unlikely that the processor speed will be very many errors; On the other hand, it is much more likely that different processor functions will matter. Many VM implementations provide ways to enable or disable certain processor functions; qemu in particular provides a high level of control over the CPU available.

+1
source

Think outside the box. What application of those that you use regularly does this? Debugger, of course! But how can you achieve this behavior to emulate a low processor?

The secret to your question is asm _int 3 . This is the assembly pause me command that is sent from the attached debugger to the application you are debugging.

Read more on int 3 for this question .

You can use the code from this tool to pause / resume the process. You can add an interval and make this tool pause your application for this period of time.

The emulated cpu speed will be: (YourCPU / Interval) -0.00001% due to alarms and other processes running on your computer, but this should do the trick.

About low memory emulation: You can create a wrapper class that allocates memory for the application and replaces each allocation with a call to this class. You could set the exact amount of memory that your application can use before it can allocate more memory.

Something like: MyClass* foo = AllocWrapper(new MyClass(arguments or whatever)); Then you can have AllocWrapper allocated / deallocated for you.

+1
source

On Linux, you can use ulimit , as Raedwald said. On Windows, you can use the SetProcessWorkingSetSize system call. But they only set a limit for each process. In fact, parts of the system will begin to fail in a stressful environment. I would suggest using the Sysinternals testlimit tool to emphasize the whole machine.

0
source

See https://serverfault.com/questions/36309/throttle-down-cpu-speed-of-vmware-image it was stated that the free VMware vSphere Hypervisor β„’ (ESXi) allows you to choose the speed of the virtual processor by setting the virtual memory size cars.

0
source

All Articles