mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Update processMemoryUsage function for posix
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
ea826db76a
commit
32281e3d22
1 changed files with 14 additions and 4 deletions
|
|
@ -79,12 +79,22 @@ static void dumpSmaps()
|
|||
|
||||
static int processMemoryUsage()
|
||||
{
|
||||
rusage usage;
|
||||
if (getrusage(RUSAGE_SELF, &usage) == 0) {
|
||||
return usage.ru_maxrss * 1024;
|
||||
} else {
|
||||
FILE* file = fopen("/proc/self/status", "r");
|
||||
if (!file) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
char line[128];
|
||||
while (fgets(line, sizeof(line), file) != NULL) {
|
||||
if (strncmp(line, "VmRSS:", 6) == 0) {
|
||||
long vmrss = atol(line + 6);
|
||||
fclose(file);
|
||||
return vmrss * 1024;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue