ganeshmurthy commented on a change in pull request #680: DISPATCH-1415, DISPATCH-1569: add process memory metric URL: https://github.com/apache/qpid-dispatch/pull/680#discussion_r378372489
########## File path: src/dispatch.c ########## @@ -379,3 +379,50 @@ void qd_dispatch_router_unlock(qd_dispatch_t *qd) { sys_mutex_unlock(qd->router- qdr_core_t* qd_dispatch_router_core(qd_dispatch_t *qd) { return qd->router->router_core; } + + +/* qd_router_memory_usage + * + * Return the amount of memory currently provisioned by the qdrouterd process. + * This includes data, stack, and code memory. On systems supporting virtual + * memory this value may be larger than the physical RAM available on the + * platform. + * + * Return 0 if the memory usage cannot be determined. + */ +uint64_t qd_router_memory_usage() +{ + // @TODO(kgiusti): only works for linux (what? doesn't everyone run linux?) + + // parse the VmSize value out of the /proc/[pid]/status file + const pid_t my_pid = getpid(); + const char *status_template = "/proc/%ld/status"; + char status_path[64]; + if (snprintf(status_path, 64, status_template, (long int)my_pid) >= 64) { Review comment: Should we used the safe_snprintf instead of snprintf ? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org