MCPcopy Create free account
hub / github.com/apple/foundationdb / getRss

Function getRss

fdbmonitor/fdbmonitor.cpp:708–730  ·  view source on GitHub ↗

Return resident memory in bytes for the given process, or 0 if error.

Source from the content-addressed store, hash-verified

706
707// Return resident memory in bytes for the given process, or 0 if error.
708uint64_t getRss(ProcessID id) {
709#ifndef __linux__
710 // TODO: implement for non-linux
711 return 0;
712#else
713 pid_t pid = id_pid[id];
714 char stat_path[100];
715 snprintf(stat_path, sizeof(stat_path), "/proc/%d/statm", pid);
716 FILE* stat_file = fopen(stat_path, "r");
717 if (stat_file == nullptr) {
718 log_msg(SevWarn, "Unable to open stat file for %s\n", id.c_str());
719 return 0;
720 }
721 long rss = 0;
722 int ret = fscanf(stat_file, "%*s%ld", &rss);
723 if (ret == 0) {
724 log_msg(SevWarn, "Unable to parse rss size for %s\n", id.c_str());
725 return 0;
726 }
727 fclose(stat_file);
728 return static_cast<uint64_t>(rss) * sysconf(_SC_PAGESIZE);
729#endif
730}
731
732void start_process(Command* cmd, ProcessID id, uid_t uid, gid_t gid, int delay, sigset_t* mask) {
733 if (!cmd->argv)

Callers 1

mainFunction · 0.85

Calls 2

log_msgFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected