MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / mi_stat_process_info

Function mi_stat_process_info

3rd/mimalloc-2.0.9/src/stats.c:493–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491static PGetProcessMemoryInfo pGetProcessMemoryInfo = NULL;
492
493static void mi_stat_process_info(mi_msecs_t* elapsed, mi_msecs_t* utime, mi_msecs_t* stime, size_t* current_rss, size_t* peak_rss, size_t* current_commit, size_t* peak_commit, size_t* page_faults)
494{
495 *elapsed = _mi_clock_end(mi_process_start);
496 FILETIME ct;
497 FILETIME ut;
498 FILETIME st;
499 FILETIME et;
500 GetProcessTimes(GetCurrentProcess(), &ct, &et, &st, &ut);
501 *utime = filetime_msecs(&ut);
502 *stime = filetime_msecs(&st);
503
504 // load psapi on demand
505 if (pGetProcessMemoryInfo == NULL) {
506 HINSTANCE hDll = LoadLibrary(TEXT("psapi.dll"));
507 if (hDll != NULL) {
508 pGetProcessMemoryInfo = (PGetProcessMemoryInfo)(void (*)(void))GetProcAddress(hDll, "GetProcessMemoryInfo");
509 }
510 }
511
512 // get process info
513 PROCESS_MEMORY_COUNTERS info;
514 memset(&info, 0, sizeof(info));
515 if (pGetProcessMemoryInfo != NULL) {
516 pGetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
517 }
518 *current_rss = (size_t)info.WorkingSetSize;
519 *peak_rss = (size_t)info.PeakWorkingSetSize;
520 *current_commit = (size_t)info.PagefileUsage;
521 *peak_commit = (size_t)info.PeakPagefileUsage;
522 *page_faults = (size_t)info.PageFaultCount;
523}
524
525#elif !defined(__wasi__) && (defined(__unix__) || defined(__unix) || defined(unix) || defined(__APPLE__) || defined(__HAIKU__))
526#include <stdio.h>

Callers 2

_mi_stats_printFunction · 0.85
mi_process_infoFunction · 0.85

Calls 3

_mi_clock_endFunction · 0.85
filetime_msecsFunction · 0.85
timeval_secsFunction · 0.85

Tested by

no test coverage detected