get_phys_pages - Online Linux Manual Page

Section : 3
Updated : 2022-10-30
Source : Linux man-pages 6.03

NAMEget_phys_pages, get_avphys_pages − get total and available physical page counts

LIBRARYStandard C library (libc, −lc)

SYNOPSIS#include <sys/sysinfo.h>"long get_phys_pages(void); long get_avphys_pages(void);

DESCRIPTIONThe function get_phys_pages() returns the total number of physical pages of memory available on the system. The function get_avphys_pages() returns the number of currently available physical pages of memory on the system.

RETURN VALUEOn success, these functions return a nonnegative value as given in DESCRIPTION. On failure, they return −1 and set errno to indicate the error.

ERRORSENOSYS  The system could not provide the required information (possibly because the /proc filesystem was not mounted).

STANDARDSThese functions are GNU extensions.

NOTESBefore glibc 2.23, these functions obtained the required information by scanning the MemTotal and MemFree fields of /proc/meminfo. Since glibc 2.23, these functions obtain the required information by calling sysinfo(2). The following sysconf(3) calls provide a portable means of obtaining the same information as the functions described on this page. total_pages = sysconf(_SC_PHYS_PAGES); /* total pages */ avl_pages = sysconf(_SC_AVPHYS_PAGES); /* available pages */

EXAMPLESThe following example shows how get_phys_pages() and get_avphys_pages() can be used. #include <stdio.h> #include <stdlib.h> #include <sys/sysinfo.h> int main(void) { printf("This system has %ld pages of physical memory and " "%ld pages of physical memory available.\n", get_phys_pages(), get_avphys_pages()); exit(EXIT_SUCCESS); }

SEE ALSOsysconf(3)
0
Johanes Gumabo
Data Size   :   7,778 byte
man-get_phys_pages.3Build   :   2025-03-22, 13:26   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   34 / 2,298,440
Visitor ID   :     :  
Visitor IP   :   216.73.217.6   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   20   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 25.03.22
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36


Very long time ago, I have the best tutor, Wenzel Svojanovsky. If someone knows the email address of Wenzel Svojanovsky, please send an email to johanesgumabo@gmail.com.
Help me, linux0001.com will expire on July 16, 2025. I have no money to renew it. View detail

If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.