On Linux, for each process, I can check /proc/PID/statm file.

It's numbers contain values of:

  • Total program size, in kilobytes
  • Size of memory portions, in kilobytes ??????
  • Number of pages that are shared

Which is great, but how do I know how much is a page?

link|improve this question

74% accept rate
feedback

3 Answers

up vote 1 down vote accepted

I'm not a Linux god (by any means) but typically page sizes are 4Kb. There's a pagesize command that should tell you what it is set to on your system. This gives the output of the getpagesize() function.

link|improve this answer
Actually, there is only the POSIX getpagesize() function. I am not aware of a pagesize command on Linux. – wzzrd Jan 5 '10 at 19:31
Yeah, function (not method). Thanks. Brain on auto there. Thought I remembered a pagesize command somewhere... Maybe was on Solaris or HP-UX... – squillman Jan 5 '10 at 19:35
Thanks, wrote "program" : #include <stdio.h> void main(){printf("%d\n",getpagesize());} and it returned 4096. thank you. – depesz Jan 5 '10 at 20:30
Really? You could have saved yourself some trouble there. If you're not on something other that your average Intel / AMD machine, it's always the same... – wzzrd Jan 5 '10 at 21:20
@wzzrd - I feel really bad about assuming something that "happens on average, usually, nearly always". – depesz Jan 6 '10 at 10:44
feedback

99% of the time a page is 4096 bytes.

link|improve this answer
feedback

On most common hardware (like AMD64 and i386), a memory page is 4 kilobytes. If I remember correctly, Sparc and some other architectures can do bigger pages, like 8kb.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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