зеркало из https://github.com/nextcloud/desktop.git
Add function to print out the status of the memory usage.
This commit is contained in:
Родитель
ef0f29f561
Коммит
48a4ad8400
|
@ -22,3 +22,33 @@
|
|||
|
||||
#include "csync_util.h"
|
||||
|
||||
#define CSYNC_LOG_CATEGORY_NAME "csync.util"
|
||||
#include "csync_log.h"
|
||||
|
||||
struct csync_memstat_s {
|
||||
int size;
|
||||
int resident;
|
||||
int shared;
|
||||
int trs;
|
||||
int drs;
|
||||
int lrs;
|
||||
int dt;
|
||||
};
|
||||
|
||||
void csync_memstat_check(void) {
|
||||
struct csync_memstat_s m;
|
||||
FILE* fp;
|
||||
|
||||
/* get process memory stats */
|
||||
fp = fopen("/proc/self/statm","r");
|
||||
if (fp == NULL) {
|
||||
return;
|
||||
}
|
||||
fscanf(fp, "%d%d%d%d%d%d%d", &m.size, &m.resident, &m.shared, &m.trs,
|
||||
&m.drs, &m.lrs, &m.dt);
|
||||
fclose(fp);
|
||||
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_INFO, "Memory: %dK total size, %dK resident, %dK shared",
|
||||
m.size * 4, m.resident * 4, m.shared * 4);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,4 +23,6 @@
|
|||
#ifndef _CSYNC_UTIL_H
|
||||
#define _CSYNC_UTIL_H
|
||||
|
||||
void csync_memstat_check(void);
|
||||
|
||||
#endif /* _CSYNC_UTIL_H */
|
||||
|
|
Загрузка…
Ссылка в новой задаче