I'm delving into multi-threaded programming with Java, but I'm finding it hard to test my program for bugs. My computer simply has too many resources and cores, making it hard to see how my program acts under stress.

Is there any way to limit the resources available to my program? It seems ridiculous that my only option right now is to open another application and render HD video in order to starve out the application I'm debugging.

  • process affinity, you can limit you program to one core that way – ratchet freak Oct 13 '13 at 16:10

Type java -X to get a whole bunch of command line options that affect available resources on the virtual machine itself. On Linux, you can also use ulimit to limit the resources for any process, which is mostly used to protect other users on multi-user systems. I don't know if there's something equivalent for windows. Try playing around with the task manager.


An easy way to limit resources is setting up a virtual machine with limited resources.


You could invest in a Raspberry Pi. The Model A costs $25 and the Model B $35.

Model A has 256MB RAM, one USB port and no Ethernet (network connection). Model B has 512MB RAM, 2 USB ports and an Ethernet port. They contain a ARM1176JZFS, with floating point, running at 700Mhz, and a Videocore 4 GPU.

Your resources most certainly will be limited with this, except for graphics power.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.