0

So , I have java code where i need to intentionally increase the CPU usage and the memory usage in order to increase the cpu's temperature.

I read a few posts including this which talk about memory leak and such...Is there something(does not need to be fairly complex) which will help me gradually increase the CPU and the memory usage and also not cause the machine to crash eventually .

Community
  • 1
  • 1
user2912902
  • 327
  • 1
  • 7
  • 17
  • You will run into issues, particularly on the memory side, with the OS. It will simply stop you from using so much resources. – David says Reinstate Monica Feb 24 '15 at 19:40
  • You really don't need to create a memory leak, just keep adding to an arraylist. Although as David says you won't be able to actually consume all memory, just all memory available to the JVM. And eventually you'll get an out of memory error which you suggest you want to avoid) – Richard Tingle Feb 24 '15 at 19:56
  • 1
    CPU usage is easy just create an endless loop (making sure it isn't *so* pointless that it's optimised out) – Richard Tingle Feb 24 '15 at 19:58
  • Actually I can catch the out of memory error and let the program continue...... – user2912902 Feb 24 '15 at 20:15

1 Answers1

3

Large floating point calculations are the most intensive units of work that can be run through the CPU. The Intel burn test is an example of software that runs a high number of these calculations over a period of time (minutes, not seconds) in order to generate heat within the CPU. Simply moving things in and out of memory will not generate that much heat.

Assuming you are on a multi-core processor, you will need to create a multithreaded application that repeatedly performs floating point calcs on large numbers. You should randomize these at runtime in order to prevent optimizations / caching from occurring.

Mike
  • 1,924
  • 14
  • 16