Using --memlock option is good way to avoid possibility of OS swapping out the server and reducing VM presure. It works at least on Linux and Solaris as well as should work on other Unix flavors. The only issue is mlockall() shall be called while processor has root priveleges. So there are two improvements to current MySQL state: 1) move memlock to the place before changing to not-root user. This would allow to run MySQL under "mysql" user while having memory locked. This is a bit tricky as this shall be in place where all important global buffers are already allocated while threads are not yet started. 2) Add an option to use ML_FUTURE instead of ML_CURRENT for memlockall() this would allow to block per thread buffers possible swapping as well as handle keycache reallocation. However it is a bit more risky if server has a chance to run out of lockable memory.