Does mysql "lock" (no other process can take from it) the memory allocated to it? I have a 64GB memory machine, and I set mysql buffer pool to be 40GB. So MySQL is using up to 40G memory while it's running.

I kicked off a java application that requires more than 20GB memory, so the java application starts to consume more and more memory and eventually the total 64G memory is not enough for both java and mysql.

Now, the interesting problem shows: mysql crashed (see graph here). But to my understand, shouldn't mysql stays the same, and instead Java crashes? Since the 40G memory is already allocated to mysql, the java application shouldn't take it away right?

Thank you
If you check kernel log, you should see OoM Killed messages.. Kernel will usually kill the largest offender which is MySQL in ourcase.