Disable swapping on Yosemite Under OS X Mavericks and below we just could launchctl unload the dynamic_pager plist, but trying to unload this plist doesn't have any effect since OS X Yosemite.

What is the new way to disable swap files now with OS X Yosemite?
Have you tried something like this?

# Check installed RAM, disable VM if 8Gb or more.

mem_inst=`/usr/sbin/sysctl -n hw.memsize`

if [ "$mem_inst" -ge "8589934592" ]; then
    echo "8Gb+ Memory installed."
        if [ "$action" == "unload" ]; then
            sudo nvram boot-args="vm_compressor=2"
            sudo pmset -a hibernatemode 0
            echo "vm.compressor_mode set to 2"
        else
            sudo nvram boot-args="vm_compressor=4"
            sudo pmset -a hibernatemode 3
            echo "vm.compressor_mode reset to defaults"
        fi
            launch_control $action /System/Library/LaunchDaemons com.apple.dynamic_pager
    else
    echo "Less than 8Gb memory."
fi


This isn't something I wrote, was information I found.