Skip to content
Snippets Groups Projects
Commit a3866435 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Add function to return the memory use of process tree

parent f9d79855
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/resource.h>
#include <sys/time.h>
/* This object's header. */ /* This object's header. */
#include "tools.h" #include "tools.h"
...@@ -701,3 +703,14 @@ int compare_particles(struct part a, struct part b, double threshold) { ...@@ -701,3 +703,14 @@ int compare_particles(struct part a, struct part b, double threshold) {
#endif #endif
} }
/**
* @brief return the resident memory use of the process and its children.
*
* @result memory use in Kb.
*/
long get_maxrss() {
struct rusage usage;
getrusage(RUSAGE_SELF, &usage);
return usage.ru_maxrss;
}
...@@ -52,4 +52,6 @@ int compare_values(double a, double b, double threshold, double *absDiff, ...@@ -52,4 +52,6 @@ int compare_values(double a, double b, double threshold, double *absDiff,
double *absSum, double *relDiff); double *absSum, double *relDiff);
int compare_particles(struct part a, struct part b, double threshold); int compare_particles(struct part a, struct part b, double threshold);
long get_maxrss();
#endif /* SWIFT_TOOL_H */ #endif /* SWIFT_TOOL_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment