MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLGetProcessMemorySize

Function CPLGetProcessMemorySize

port/cpl_error.cpp:524–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522
523#ifdef __linux
524static int CPLGetProcessMemorySize()
525{
526 FILE *fp = fopen("/proc/self/status", "r");
527 if (fp == nullptr)
528 return -1;
529 int nRet = -1;
530 char szLine[128] = {};
531 while (fgets(szLine, sizeof(szLine), fp) != nullptr)
532 {
533 if (STARTS_WITH(szLine, "VmSize:"))
534 {
535 const char *pszPtr = szLine;
536 while (!(*pszPtr == '\0' || (*pszPtr >= '0' && *pszPtr <= '9')))
537 pszPtr++;
538 nRet = atoi(pszPtr);
539 break;
540 }
541 }
542 fclose(fp);
543 return nRet;
544}
545#else
546#error CPLGetProcessMemorySize() unimplemented for this OS
547#endif

Callers 1

CPLvDebugFunction · 0.85

Calls 2

fopenFunction · 0.85
fcloseFunction · 0.85

Tested by

no test coverage detected