This can be done via WHM

You can change the memory limt for cpanel from the WHM >> Tweak settings

You will find the option "The maximum memory a cPanel process can use before it is killed off (in megabytes). Values less than 128 megabytes can not be specified. A value of "0" will disable the memory limits."

Change the desired memory limt in the box according to the memory available on the server.

If the server is having more memory you can set 512-1G to cpanel.