The CreateSpec class allows you to specify the CPU and memory configuration of a virtual machine.

To change the CPU and memory configuration settings, use the CpuTypes.UpdateSpec and MemoryTypes.UpdateSpec classes.

CPU Configuration

You can set the number of CPU cores in the virtual machine by using the setCount method of the CpuTypes.UpdateSpec class. The supported range of CPU cores depends on the guest operating system and virtual hardware version of the virtual machine. If you set CpuTypes.Info.getHotAddEnabled() and CpuTypes.Info.getHotRemoveEnabled() to true, you allow virtual processors to be added or removed from the virtual machine at runtime.

Memory Configuration

You can set the memory size of a virtual machine by using the setSizeMiB method of the MemoryTypes.UpdateSpec class. The supported range of memory sizes depends on the configured guest operating system and virtual hardware version of the virtual machine. If you set MemoryTypes.UpdateSpec.setHotAddEnabled() to true while the virtual machine is not powered on, you enable adding memory while the virtual machine is running.