Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current memory page size in C#

I need to determine the memory page size in C# without using "Kernel32.dll"

SYSTEM_INFO si;
GetSystemInfo(&si);

This is very important because the code should be cross platform and we should not have platform specific code.

Is there any .NET class which provides that data?

like image 253
Pandichie Anton-Valentin Avatar asked Jun 16 '15 12:06

Pandichie Anton-Valentin


People also ask

How do I get the size of a page in C++?

The getpagesize() function returns the current page size. The getpagesize() function is equivalent to sysconf(_SC_PAGE_SIZE) and sysconf(_SC_PAGESIZE).

What is Pagesize in Linux?

The pagesize command prints the size, in bytes, of a page of memory, as returned by the getpagesize subroutine. Provided for system compatibility, this command is useful when constructing portable shell scripts.


1 Answers

Try Environment.SystemPageSize:

Gets the number of bytes in the operating system's memory page.

Requires .NET >= 4.0

In the remarks it is even written that:

In Windows, this value is the dwPageSize member in the SYSTEM_INFO structure.

like image 88
xanatos Avatar answered Sep 26 '22 22:09

xanatos