Much better algorithm for VM memory change.