westonpace commented on a change in pull request #12702:
URL: https://github.com/apache/arrow/pull/12702#discussion_r837987266
##########
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:
Ah, yes, I see now that you are grabbing all three numbers.
`GetMemoryUsed` is less interesting than `GetMemoryUsedByProcess` in my opinion
but I don't think it would hurt to report it.
> but after that PR get merged I can add another function for get that, and
don't use system includes here.
That PR that I linked to will not be merged. We ended up pursuing a
different approach. So we don't want to wait on it. However, you're welcome
to copy the approach that was being taken for this method.
--
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]