0

I have a daemon written in C running under a RHEL 4 machine.

The daemon access a segment of shared memory (nothing more than a big array of 65536 elements). No malloc/free are done.

I observed that ps aux shows that the daemon has the size of shared memory + some kb as VSZ and just some kb as RSS.

Then, the more the daemon access shared memory array, the more RSS increase until reaching circa the same size of VSZ.

Why Linux calculate the RSS in this way?

I mean... shared memory shouldn't be ignored as memory consumpted (RSS) by a single process, because it can be accessed by many others runnables?

And why it raise the RSS just accessing shared memory?

Davide Berra
  • 6,387
  • 2
  • 29
  • 50

1 Answers1

1

RSS is the amount of physical memory mapped to your process.

Linux employs demand paging so that physical memory only gets mapped on the first access. VSZ is virtual memory which gets backed by physical memory on demand. This explains why your RSS grows as you access more of the shared memory mapping.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271