public static void lockMemory() {
    try {
      Native.register(Platform.C_LIBRARY_NAME);
      int result = mlockall(1);
      if (result == 0) {
        return;
      }
    } catch (Throwable t) {
      throw new IllegalStateException("Error trying to lock memory", t);
    }

    int lastError = Native.getLastError();
    String message = "mlockall failed: " + lastError;
    if (lastError == 1 || lastError == 12) {
      // if EPERM || ENOMEM
      message = "Unable to lock memory due to insufficient free space or privileges.  "
          + "Please check the RLIMIT_MEMLOCK soft resource limit (ulimit -l) and "
          + "increase the available memory if needed";
    }
    throw new IllegalStateException(message);
  }
Invokes mlockall(). Locks all pages mapped into the address space of the calling process. This
includes the pages of the code, data and stack segment, as well as shared libraries, user space
kernel data, shared memory, and memory-mapped files. All mapped pages are guaranteed to be
resident in RAM when the call returns successfully; the pages are guaranteed to stay in RAM
until later unlocked.

@param flags MCL_CURRENT 1 - Lock all pages which are currently mapped into the address space
       of the process.

       MCL_FUTURE 2 - Lock all pages which will become mapped into the address space of the
       process in the future. These could be for instance new pages required by a growing heap
       and stack as well as new memory mapped files or shared memory regions.

@return 0 if success, non-zero if error and errno set
geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java