How To Solve Issues Related to Log – Unable to lock JVM Memory: error=

Get an Elasticsearch Check-Up

Check if your ES issues are caused from misconfigured settings
(Free 2 min process)

Check-Up

Last update: Feb-20

Elasticsearch Error Guide In Page Navigation (click to jump) :

Troubleshooting Background – start here to get the full picture       
Related Issues – selected resources on related issues  
Log Context – usefull for experts
About Opster – offering a diffrent approach to troubleshoot Elasticsearch

Check Your Elasticsearch Settings for Painfull Mistakes 


Troubleshooting background

To troubleshoot Elasticsearch log “Unable to lock JVM Memory: error=” it’s important to know common problems related to Elasticsearch concepts: bootstrap. See below-detailed explanations complete with common problems, examples and useful tips.

Memory in Elasticsearch

What is it

Memory is one of the most critical resources to monitor in Elasticsearch. Elasticsearch runs on JVM and uses heap memory areas for query cache, request cache, accessing lucene segments and storing fielddata for aggregations and sorting.

Commos problems and important points
  • The most common error that arises in Elasticsearch is OutOfMemory error. This error comes when the node is not able to cope up with the required heap size space. To avoid this, you need to closely monitor the heap utilization and garbage collector performance.
  • As per the most up-to-date best practices you should not allocate more than 50 percent of total RAM to JVM heap size. Starting from Elasticsearch version 5.x onward this can be set using -Xms and -Xmx parameters inside jvm.options configuration file. The defaults are set to 1 GB for both minimum and maximum heap size.
  • The heap size should not set more than 31 GB in any case to avoid the poor garbage collection.

To help troubleshoot related issues we have gathered selected Q&A from the community and issues from Github , please review the following for further information :

1. Unable to lock JVM Memory: error=12, reason=Cannot allocate memory – Elasticsearch 6.2.4 – Stats : ♥ 5.38 K  Ι √ 5

2. Es 5 0 0 Alpha5 Unable To Lock Jvm      


Log Context

Log ”Unable to lock JVM Memory: error=” classname is JNANatives.java
We have extracted the following from Elasticsearch source code to get an in-depth context :

             // this will have already been logged by CLibrary; no need to repeat it
            return;
        }

        // mlockall failed for some reason
        logger.warn("Unable to lock JVM Memory: error=" + errno + ";reason=" + errMsg);
        logger.warn("This can result in part of the JVM being swapped out.");
        if (errno == JNACLibrary.ENOMEM) {
            if (rlimitSuccess) {
                logger.warn("Increase RLIMIT_MEMLOCK; soft limit: " + rlimitToString(softLimit) + "; hard limit: " + rlimitToString(hardLimit));
                if (Constants.LINUX) {






About Opster

Incorporating deep knowledge and broad history of Elasticsearch issues. Opster’s solution identifies and predicts root causes of Elasticsearch problems, provides recommendations and can automatically perform various actions to manage, troubleshoot and prevent issues

Learn more: Glossary | Blog| Troubleshooting guides | Error Repository

Need help with any Elasticsearch issue ? Contact Opster

Did this page help you?