how to increase cpu load

can someone suggest me some code in any language that will increase CPU and memory both.

google for this:

sourceforge.net: stress test

Assuming you want to clobber your system to test something.

I have already tried stress.

  stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s 

It increase mostly server load, while i need to increase CPU/MEM.

Use the proper options:

$ stress --cpu X --vm 1 --vm-bytes=Y

where Y is the number of your cpus, and Y the amount of memory you want to be used. For example, for a 4 cpu system with 6GB free memory, you could use:

$ stress --cpu 4 --vm 1 --vm-bytes=5G

Or use Prime95: Free Software - GIMPS, which is more stressing.

To test the ram from inside the OS, you can use memtester: memtester version 4
--
Bye