MCPcopy Create free account
hub / github.com/BirolLab/abyss / getMemoryUsage

Function getMemoryUsage

Common/MemoryUtil.h:23–42  ·  view source on GitHub ↗

Return the number of bytes used by the data and stack segments. * @return -1 on error */

Source from the content-addressed store, hash-verified

21 * @return -1 on error
22 */
23static inline ssize_t getMemoryUsage()
24{
25#if __MACH__
26 struct task_basic_info t_info;
27 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
28 int status = task_info(mach_task_self(),
29 TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
30 assert(status == KERN_SUCCESS);
31 return status == KERN_SUCCESS ? (ssize_t)t_info.virtual_size : -1;
32#elif HAVE_GETPAGESIZE
33 std::ifstream in("/proc/self/statm");
34 size_t size, resident, share, text, lib, data;
35 return in >> size >> resident >> share >> text >> lib >> data
36 ? ssize_t(data * getpagesize()) : -1;
37#else
38 /** Start of the data segment. */
39 static intptr_t sbrk0 = reinterpret_cast<intptr_t>(sbrk(0));
40 return reinterpret_cast<intptr_t>(sbrk(0)) - sbrk0;
41#endif
42}
43
44#endif

Callers 9

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
readPathsFunction · 0.85
mainFunction · 0.85
printLoadMethod · 0.85
printProgressFunction · 0.85
printProgressFunction · 0.85
printProgressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected