For testing some monitoring software on my Linux system I needed to use up most of the RAM using basic Linux commands. The following worked quite well for me:
cat /dev/zero | head -c 3G | tail
If the buffer specified is too large to fit into the RAM, you will see a message similar to the one shown below. In that case, just use a smaller number.
tail: memory exhausted