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?

Upvotes: 5

Views: 3213

Answers (1)

xanatos
xanatos

Reputation: 111870

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.

Upvotes: 6

Related Questions