Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C# Program to Get the Memory Size For OS Page File using Environment Class

  • Last Updated : 24 Oct, 2021

Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since last system boot in milliseconds information. In this article, we will discuss how to find the memory size for the OS Page file. So we can find the memory size of the OS page file by using the SystemPageSize property. This property returns the number of bytes present in the operating system’s memory page.

Syntax:

Environment.SystemPageSize

Return Type: The return type of this property is an integer.

Example:



C#




// C# program to find the size of operating 
// system's memory page. Using Environment Class
using System;
  
class GFG{
      
static public void Main()
{
    // Declare a variable
    int result;
      
    // Now we find the memory size for OS Page file 
    // Using SystemPageSize property of Environment class
    result = Environment.SystemPageSize;
      
    // Display the result
    Console.WriteLine("The memory size for OS page file is " + result);
}
}

Output:

The memory size for OS page file is 4096

Example 2:

C#




// C# program to find the size of operating 
// system's memory page. Using Environment Class
using System;
  
class GFG{
      
static public void Main()
{
      
    // Arithmetic operation
    int Sum = 1 + 3;
    Console.WriteLine("Sum:" + Sum);
      
    // Declare a variable
    int res;
      
    // Now we find the memory size for OS Page file 
    // Using SystemPageSize property of Environment class
    res = Environment.SystemPageSize;
      
    // Display the result
    Console.WriteLine("The memory size for OS page file is " + res);
}
}

Output:

Sum:4
The memory size for OS page file is 4096



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!