ATLAS Offline Software
Loading...
Searching...
No Matches
read_athena_statm.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  athena_statm

Functions

struct athena_statm read_athena_statm ()

Function Documentation

◆ read_athena_statm()

struct athena_statm read_athena_statm ( )

Definition at line 15 of file read_athena_statm.cxx.

16{
17 struct athena_statm res = {0, 0, 0};
18#ifndef __APPLE__
19
20 const char *filename = "/proc/self/statm";
21 FILE* fd = fopen(filename, "r");
22 if (0==fd) {
23 char errbuf[1024];
24 strerror_r (errno, errbuf, sizeof(errbuf));
25 fprintf(stderr,
26 "read_statm: problem opening file %s:\n%s\n", filename, errbuf);
27 return res;
28 }
29
30 if (fscanf(fd, "%80u %80u %80u", &res.vm_pages, &res.rss_pages, &res.shr_pages) < 3) {
31 fprintf(stderr,
32 "read_statm: problem reading file %s:\n", filename);
33 }
34 fclose(fd);
35#else
36 int pagesize = getpagesize();
37 struct task_basic_info t_info;
38 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
39 if (KERN_SUCCESS == task_info(mach_task_self(),
40 TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count)) {
41 // On the Mac, the virtual and resident sizes are returned in units of bytes
42 // whereas CoreDumpSvc expects them to be returned in units of pages
43 res.vm_pages = t_info.virtual_size/pagesize;
44 res.rss_pages = t_info.resident_size/pagesize;
45 }
46#endif
47 return res;
48}
std::pair< std::vector< unsigned int >, bool > res