This is difficult, but what you essentially need is for a separate process to consume all of the available RAM, locking its own data into physical RAM, but leaving all of the swap available (you should be able to see the effect using the 'free' command)
I think there are already tools out there to do this (I don't recall any specific examples, but there are tools to fill up memory or test memory for bit errors while the system is running... that type of thing) or something close to it.
My question is ... why? Why intentionally cripple the test machine only to get number that is highly specific to your swap configuration (disk type, size, rotation rate, etc)? Also, how resource intensive is your application in the first place? If it isn't very (say a meg or two of RAM), then swapping won't hurt very badly.
You simply can't run directly out of the "swap device". The CPU can't execute code that isn't in RAM. Nor can it access data that isn't in RAM. Data and code on the hard drive must be read into RAM before the CPU can execute it or access it. – Jamie Hanrahan – 2018-02-21T10:34:44.780
Correct, I didn't mean to say "virtual memory", but rather the swap device, bypassing RAM as you wrote. Yeah, I didn't want to have to setup a new system, but I'm almost convinced that that will be the easier way to go. – Everaldo Aguiar – 2010-12-09T05:04:55.733