I am getting Out of Memory errors while my swap isn't touched. I have 4GB of ram and 4GB of swap space. I enabled the swap via swapon and when doing free, I see the swap listed there.

I'm thinking that perhaps there is some issue with overlayfs / tmpfs and swap all working together. I have always had the opposite problem, trying to prevent swap usage, so I can't seem to figure out what changed.

Also, I am using a grsecurity enabled kernel. Is it possible that memory allocation work differently under there?

Snapshot of free:

                      total        used        free      shared  buff/cache   available
          Mem:        3586392      157292       67052      141664     3362048     3236524
          Swap:       4194300           0     4194300

After I added the swap configuration to /etc/fstab, these numbers have changed; however, I still don't see any swap usage. The only other thing I changed was the tmpfs size for /dev/shm and my overlayfs volume (/rw). Both of which were not using much space to begin with, so the change should not have had any impact.

                      total        used        free      shared  buff/cache   available
          Mem:        3586392      571392     1714036      146096     1300964     2818004
          Swap:       4194300           0     4194300

I restarted a bunch of services and they're still running, and the biggest difference I see is that free memory is now showing 1.7GB free versus 67MB prior.

I'm still confused as to why that had any impact. If I enable swap through swapon, it should behave the same way as if I configure it through /etc/fstab and do swapon -a. Furthermore, it isn't even being used yet anyways.

  • have you checked if user-limits are in effect? check with ulimit -v for a memory limit. A second thought: if you are using a java program then you have to check the memory parameters of the java-vm.
    – murphy
    Oct 9, 2016 at 6:52
  • I don't have user limits in effect, and I don't have a java program eating up the memory. Why would that matter - don't I have a total of 8GB of memory that can be allocated roughly?
    – Walter
    Oct 9, 2016 at 10:43
  • 3
    The jvm doesn't use all available memory. So if the program that gets an OOM is java-based, it is maybe limited by the jvm not the os.
    – murphy
    Oct 9, 2016 at 11:23
  • I later got an OOM even after the above changes, so nothing really changed.
    – Walter
    Oct 11, 2016 at 13:29
  • The peculiar thing is that I have about 3.2GB acting as a cache / buffer while only about 200MB is actually used according to free. Memory usage / free space isn't being calculated properly, because, if the machine were truly out of memory, shouldn't the cache be discarded for actual use?
    – Walter
    Oct 16, 2016 at 3:50

1 Answer 1


This was a bug with the version of the kernel I was using.

  • 2
    It might help if you tell what kernel version it was, even better a link to the bug description.
    – jlliagre
    Nov 21, 2016 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.