Получем использование RAM на Си

This commit is contained in:
Alexander Popov 2024-03-07 21:29:50 +03:00
parent 1cb337c7b1
commit c844ea9749
2 changed files with 12 additions and 1 deletions

View File

@ -3,7 +3,7 @@
## Other
- [seconds_to_minutes_and_hours.c](seconds_to_minutes_and_hours.c) - Преобразование секунд в минуты и часы
- [get_ram_usage.c](get_ram_usage.c) - Получение используемой приложением RAM
## SQLite 3
- [CREATE TABLE](sqlite/sqlite3_create.c)

11
code/C/get_ram_usage.c Normal file
View File

@ -0,0 +1,11 @@
#include <sys/resource.h>
#include <stdio.h>
int main() {
struct rusage r_usage;
getrusage(RUSAGE_SELF, &r_usage);
printf("Memory usage: %ld kilobytes\n", r_usage.ru_maxrss);
return 0;
}