master
h 43 lines 1.18 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_PROCESS_MEMORY_H
4 #define NETDATA_PROCESS_MEMORY_H
5
6 #include "libnetdata/libnetdata.h"
7
8 /**
9 * Process memory information
10 *
11 * This structure contains memory usage information for a process.
12 */
13 typedef struct {
14 uint64_t rss; // Resident Set Size in bytes
15 uint64_t virtual_size; // Virtual memory size in bytes
16 uint64_t shared; // Shared memory in bytes
17 uint64_t text; // Text (code) size in bytes
18 uint64_t data; // Data size in bytes
19 uint64_t max_rss; // Peak resident set size in bytes
20 } OS_PROCESS_MEMORY;
21
22 /**
23 * Check if the process memory information is valid
24 */
25 #define OS_PROCESS_MEMORY_OK(proc_mem) ((proc_mem).rss > 0)
26
27 /**
28 * Empty process memory structure
29 */
30 #define OS_PROCESS_MEMORY_EMPTY (OS_PROCESS_MEMORY){ 0 }
31
32 /**
33 * Get process memory information
34 *
35 * Returns memory information for the specified process, or the current
36 * process if pid is 0.
37 *
38 * @param pid The process ID or 0 for current process
39 * @return OS_PROCESS_MEMORY The memory information
40 */
41 OS_PROCESS_MEMORY os_process_memory(pid_t pid);
42
43 #endif // NETDATA_PROCESS_MEMORY_H