KDK_RTI_GET_MEM_RES_USAGE_PERCENT(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

🎀 NAME

kdk_rti_get_mem_res_usage_percent — 获取物理内存使用率 (aka "how much of my RAM is actually being used rn bestie") 💖

This one lives in the Library Functions Manual, section 3, and yes she's a whole icon.


✨ SYNOPSIS

#include <libkyrtinfo.h>

extern float kdk_rti_get_mem_res_usage_percent();

Link with -lkyrtinfo.


💖 DETAILED DESCRIPTION

okay so the main character job of this interface? it grabs the physical memory usage rate. that's it, that's the vibe. she's the one who tells you what percentage of your physical memory is currently doing the most. 🫶


🔥 RETURN VALUE

  • On success — returns the physical memory usage rate, type float. slay. ✨
  • On error — returns 0.00. 💀 not the zero, but okay.

🌸 EXAMPLES

here's the full lil program, copy-paste energy, no cap:

#include "libkyrtinfo.h"
#include <stdio.h>

int main()
{
    printf("内存总大小:%lu KiB0, kdk_rti_get_mem_res_total_KiB());
    printf("当前已用内存:%lu KiB,%f0, kdk_rti_get_mem_res_usage_KiB(), kdk_rti_get_mem_res_usage_percent());
    printf("当前空闲内存:%lu KiB0, kdk_rti_get_mem_res_free_KiB());
    printf("可用内存大小:%lu KiB0, kdk_rti_get_mem_res_available_KiB());
    printf("应用总申请虚拟内存大小:%lu KiB0, kdk_rti_get_mem_virt_alloc_KiB());
    printf("交换分区总量:%lu KiB0, kdk_rti_get_mem_swap_total_KiB());
    printf("交换分区已用量:%lu KiB, %f0, kdk_rti_get_mem_swap_usage_KiB(), kdk_rti_get_mem_swap_usage_percent());
    printf("交换分区剩余大小:%lu KiB0, kdk_rti_get_mem_swap_free_KiB());
    printf("当前CPU使用率:%f0, kdk_rti_get_cpu_current_usage());
    unsigned int day, hour, min, sec;
    kdk_rti_get_uptime(&day, &hour, &min, &sec);
    printf("开机时长:%u天%u小时%u分钟%u秒0, day, hour, min, sec);
    return 0;
}
bestie I am begging you — that code is copied character-for-character from the original page. do not "fix" the quotes or the parens. it is what it is. 🙈

👑 CONFORMING TO

These functions are as per the withdrawn POSIX.1e draft specification. (withdrawn?? the drama. the lore. 😭)

The following functions are Linux extensions:

  • kdk_rti_get_mem_res_total_KiB()
  • kdk_rti_get_mem_res_usage_KiB()
  • kdk_rti_get_mem_res_available_KiB()
  • kdk_rti_get_mem_res_free_KiB()
  • kdk_rti_get_mem_virt_alloc_KiB()
  • kdk_rti_get_mem_swap_total_KiB()
  • kdk_rti_get_mem_swap_usage_percent()
  • kdk_rti_get_mem_swap_usage_KiB()
  • kdk_rti_get_mem_swap_free_KiB()
  • kdk_rti_get_cpu_current_usage()
  • kdk_rti_get_uptime()

🦋 SEE ALSO

the whole friend group, go say hi 💅


and that's the whole page, bestie!! 🌈⭐ this one came from the Linux Programmer's Manual, dated Mon Sep 18 2023, and it's filed under KDK_RTI_GE...AGE_PERCENT(3). periodt. 💜🦋✨

📦 where this page comes from