0

I have an ongoing discussion with the support of one of the cloud services. The problem is that we get "Cannot allocate memory" errors (for allocating shared memory segments by PostgreSQL) despite their "Freeable Memory" and "Free Swap" metrics showing large amounts of available memory.

The support claims that it's because the shared/buffers memory (IO cache) is in "active state so it could not be directly deallocated" and that the reassignment of the memory from the buffers to the application isn't instant and that it takes some time.

To my knowledge, this is not true, as the Linux kernel is always able to instantly reassign memory from I/O cache to an application. Am I right?

  • Is this an openvz VPS? – jordanm Jul 19 '19 at 13:27
  • No, it's AWS EC2. – Artur Siekielski Jul 19 '19 at 13:29
  • Do you mean RDS? Cloudwatch doesn't provide memory metrics for EC2 instances. – jordanm Jul 19 '19 at 13:31
  • Yes, it's EC2 RDS instance. So I think we can have a problem because AWS uses a proprietary virtualization technology? But getting the answer to my question for a vanilla Linux kernel would be also helpfu. – Artur Siekielski Jul 19 '19 at 13:32
  • My suspicion is that their "Freeable Memory" metric doesn't exclude shared memory segments. So the actual "available" memory is lower than what "Freeable Memory" shows. – Artur Siekielski Jul 19 '19 at 13:40
0

No. The eventual freeing of the memory is done by the operating system, and that could very well take it's time in doing so. Memory will probably be reclaimed when it is needed for something else, at some random time in the future.

If you wonder if it will be cleared on release, it is very unlikely, doing so takes extra work for no good reason. You should scrub and then release if the memory contains sensitive data.

| improve this answer | |
  • I think you misunderstood the question. It's not about whether the kernel writes zeros to the memory before giving it back to a process, it's whether is it possible that there's large amount of cached/buffered memory but the kernel is unable to re-assign it instantly to a process, and returns an "out of memory" error to the process. – Artur Siekielski Jul 19 '19 at 15:37

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.