Is there a portable way to detect (programmatically) the memory page size using C or C++ code ?
+3
A:
C doesn't know anything about memory pages. On posix systems you can use long pagesize = sysconf(_SC_PAGE_SIZE);
nos
2010-07-28 10:28:12
+5
A:
Since Boost
is a pretty portable library you could use mapped_region::get_page_size()
function to retrieve the memory page size.
As for C++ Standard it gives no such a possibility.
Kirill V. Lyadvinsky
2010-07-28 10:33:26
+2
A:
It is entirely platform dependent which address-ranges are mapped to which page-sizes. Further the pagesize is not system-wide. You can allocate memory from different page-size regions according to the use case. And you can even have platforms without any virtual memory managment.
So, code handling this topic must be platform specific.
DarthCoder
2010-07-28 12:13:45