AlvinJ15 commented on a change in pull request #12702:
URL: https://github.com/apache/arrow/pull/12702#discussion_r837933770



##########
File path: cpp/src/arrow/util/tracing_internal.cc
##########
@@ -184,6 +188,41 @@ opentelemetry::trace::Tracer* GetTracer() {
   return tracer.get();
 }
 
+int parseLine(char* line){
+  // This assumes that a digit will be found and the line ends in " Kb".
+  int i = strlen(line);
+  const char* p = line;
+  while (*p <'0' || *p > '9') p++;
+  line[i-3] = '\0';
+  i = atoi(p);
+  return i;
+}
+
+size_t GetMemoryUsedByProcess() { //Note: this value is in KB!
+  FILE* file = fopen("/proc/self/status", "r");
+  size_t result = -1;
+  char line[128];
+
+  while (fgets(line, 128, file) != NULL){
+    if (strncmp(line, "VmRSS:", 6) == 0){
+      result = parseLine(line);
+      break;
+    }
+  }
+  fclose(file);
+  return result*1000;
+}
+
+size_t GetMemoryUsed() {
+  size_t total_memory_size;
+  size_t used_memory_size;
+  struct sysinfo si;
+  sysinfo(&si);

Review comment:
       @westonpace I get the bytes from the memory pool in the first span, but 
in the next ones I extracted the statistics from the sysinfo for report the 
RSS, I looked the PR which you mentioned, and there the method return just the 
FreeRam and for calculate the Current Ram in used I still need to use 
sysinfo.total_memory, but after that PR get merged I can add another function 
for get that, and don't use system includes here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to