Commit 2c8c6634 authored by hrchilds's avatar hrchilds
Browse files

Add a method for tracking memory usage.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@3361 18c085ea-50e0-402c-830e-de6fd14e8384
parent 96edd9a1
......@@ -206,6 +206,41 @@ LongestCommonSuffixLength(const char * const *list, int listN)
}
// ****************************************************************************
// Function: GetMemorySize
//
// Purpose:
// Gets the amount of memory in use and the RSS (resident set size).
//
// Programmer: Hank Childs (from code from Peter Lindstrom)
// Creation: February 28, 2008
//
// ****************************************************************************
void
GetMemorySize(int &size, int &rss)
{
size = -1;
rss = -1;
#if !defined(_WIN32)
FILE *file = fopen("/proc/self/statm", "r");
if (file == NULL)
{
return;
}
int count = fscanf(file, "%d%d", &size, &rss);
if (count != 2)
{
return;
}
size *= getpagesize();
rss *= getpagesize();
fclose(file);
#endif
}
// ****************************************************************************
// Function: WaitUntilFile
//
......
......@@ -89,6 +89,9 @@ bool UTILITY_API ReadAndProcessDirectory(const std::string &,
bool = false);
std::string UTILITY_API ExpandUserPath(const std::string &);
// LINUX ONLY
void UTILITY_API GetMemorySize(int &, int &);
void UTILITY_API WaitUntilFile(const char *);
bool UTILITY_API WildcardStringMatch(const char *p, const char *s);
bool UTILITY_API WildcardStringMatch(const std::string &p, const std::string &s);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment