5

You can adjust the memory overcommit policy system-wide via sysctl calls, but is it possible to adjust this policy on a per-process basis from within the process itself?

I want to make one particular real-time process never use overcommit, though the rest of the system can overcommit.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Joe
  • 7,378
  • 4
  • 37
  • 54
  • Not sure if you really can. One solution would be to set the `memlock` limit of the user running the application to a large enough value (see limits.conf(5)) and use `mlock(2)` on sensitive memory zones. – fge Dec 21 '11 at 11:27
  • Not an option as the user is root and there are many root level apps running at various real time priorities on this embedded box. It would be a change across multiple processes, rather than the one I need. – Joe Dec 21 '11 at 11:39
  • Well, root _can_ mlock(2) everything it wants by default! I've had hope that it did not run as root :p – fge Dec 21 '11 at 11:45
  • mlockall can't know to allocate everything that is run time allocated on the heap after its call, no? It just prevents it being swapped out. Or does it defeat overcommit after its call? – Joe Dec 21 '11 at 12:11
  • No it doesn't, it's only for dynamically allocated memory. – fge Dec 21 '11 at 12:52

1 Answers1

2

No, it's not possible.

Somewhat related, for a real-time process, you probably want to use the mlock or mlockall functions to pin your address space to RAM.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
janneb
  • 36,249
  • 2
  • 81
  • 97
  • Yup, already locked into RAM.At the moment I memset all the memory I want allocated to make sure I have it, I just wondered if this was superfluous and a simple call at the top of the app could switch off overcommit. – Joe Dec 21 '11 at 11:29