How to limit RAM in an OSX device?
Create a ram disk :-)
From the answer to Mount a RAM disk on boot:

You can create and mount a RAM disk with the following Terminal (i.e. shell) command:
diskutil erasevolume HFS+ &quot;diskName&quot; $(hdiutil attach -nomount ram://2048)

Where 2048 can be any number and represents the number of 512 byte blocks you want to allocate. So 1,000,000 will get you 512,000,000 bytes. (Of course, you have to leave out the commas.)

So in your case the command would be
diskutil erasevolume HFS+ &quot;diskName&quot; $(hdiutil attach -nomount ram://$((8*2**30/512)))