Skip to content
Snippets Groups Projects
Commit 017a23aa authored by Leslie Linden's avatar Leslie Linden
Browse files

SH-2218 WORK AROUND -- v2.8.x Viewers crash consistently when I actively use other applications

* Just removed mac memory stats to make a low-risk work-around.
parent 01ee25cc
No related branches found
No related tags found
No related merge requests found
...@@ -1003,184 +1003,6 @@ LLSD LLMemoryInfo::loadStatsMap() ...@@ -1003,184 +1003,6 @@ LLSD LLMemoryInfo::loadStatsMap()
LL_WARNS("LLMemoryInfo") << "Unable to collect hw.memsize memory information" << LL_ENDL; LL_WARNS("LLMemoryInfo") << "Unable to collect hw.memsize memory information" << LL_ENDL;
} }
FILE* pout = popen("vm_stat 2>&1", "r");
if (! pout) // popen() couldn't run vm_stat
{
// Save errno right away.
int popen_errno(errno);
LL_WARNS("LLMemoryInfo") << "Unable to collect vm_stat memory information: ";
char buffer[256];
if (0 == strerror_r(popen_errno, buffer, sizeof(buffer)))
{
LL_CONT << buffer;
}
else
{
LL_CONT << "errno " << popen_errno;
}
LL_CONT << LL_ENDL;
}
else // popen() launched vm_stat
{
// Mach Virtual Memory Statistics: (page size of 4096 bytes)
// Pages free: 462078.
// Pages active: 142010.
// Pages inactive: 220007.
// Pages wired down: 159552.
// "Translation faults": 220825184.
// Pages copy-on-write: 2104153.
// Pages zero filled: 167034876.
// Pages reactivated: 65153.
// Pageins: 2097212.
// Pageouts: 41759.
// Object cache: 841598 hits of 7629869 lookups (11% hit rate)
// Intentionally don't pass the boost::no_except flag. These
// boost::regex objects are constructed with string literals, so they
// should be valid every time. If they become invalid, we WANT an
// exception, hopefully even before the dev checks in.
boost::regex pagesize_rx("\\(page size of ([0-9]+) bytes\\)");
boost::regex stat_rx("(.+): +([0-9]+)\\.");
boost::regex cache_rx("Object cache: ([0-9]+) hits of ([0-9]+) lookups "
"\\(([0-9]+)% hit rate\\)");
boost::cmatch matched;
LLSD::Integer pagesizekb(4096/1024);
// Here 'pout' is vm_stat's stdout. Search it for relevant data.
char line[100];
line[sizeof(line)-1] = '\0';
while (fgets(line, sizeof(line)-1, pout))
{
size_t linelen(strlen(line));
// Truncate any trailing newline
if (line[linelen - 1] == '\n')
{
line[--linelen] = '\0';
}
LL_DEBUGS("LLMemoryInfo") << line << LL_ENDL;
if (regex_search_no_exc(line, matched, pagesize_rx))
{
// "Mach Virtual Memory Statistics: (page size of 4096 bytes)"
std::string pagesize_str(matched[1].first, matched[1].second);
try
{
// Reasonable to assume that pagesize will always be a
// multiple of 1Kb?
pagesizekb = boost::lexical_cast<LLSD::Integer>(pagesize_str)/1024;
}
catch (const boost::bad_lexical_cast&)
{
LL_WARNS("LLMemoryInfo") << "couldn't parse '" << pagesize_str
<< "' in vm_stat line: " << line << LL_ENDL;
continue;
}
stats.add("page size", pagesizekb);
}
else if (regex_match_no_exc(line, matched, stat_rx))
{
// e.g. "Pages free: 462078."
// Strip double-quotes off certain statistic names
const char *key_begin(matched[1].first), *key_end(matched[1].second);
if (key_begin[0] == '"' && key_end[-1] == '"')
{
++key_begin;
--key_end;
}
LLSD::String key(key_begin, key_end);
LLSD::String value_str(matched[2].first, matched[2].second);
LLSD::Integer value(0);
try
{
value = boost::lexical_cast<LLSD::Integer>(value_str);
}
catch (const boost::bad_lexical_cast&)
{
LL_WARNS("LLMemoryInfo") << "couldn't parse '" << value_str
<< "' in vm_stat line: " << line << LL_ENDL;
continue;
}
// Store this statistic.
stats.add(key, value);
// Is this in units of pages? If so, convert to Kb.
static const LLSD::String pages("Pages ");
if (key.substr(0, pages.length()) == pages)
{
// Synthesize a new key with kb in place of Pages
LLSD::String kbkey("kb ");
kbkey.append(key.substr(pages.length()));
stats.add(kbkey, value * pagesizekb);
}
}
else if (regex_match_no_exc(line, matched, cache_rx))
{
// e.g. "Object cache: 841598 hits of 7629869 lookups (11% hit rate)"
static const char* cache_keys[] = { "cache hits", "cache lookups", "cache hit%" };
std::vector<LLSD::Integer> cache_values;
for (size_t i = 0; i < (sizeof(cache_keys)/sizeof(cache_keys[0])); ++i)
{
LLSD::String value_str(matched[i+1].first, matched[i+1].second);
LLSD::Integer value(0);
try
{
value = boost::lexical_cast<LLSD::Integer>(value_str);
}
catch (boost::bad_lexical_cast&)
{
LL_WARNS("LLMemoryInfo") << "couldn't parse '" << value_str
<< "' in vm_stat line: " << line << LL_ENDL;
continue;
}
stats.add(cache_keys[i], value);
}
}
else
{
LL_WARNS("LLMemoryInfo") << "unrecognized vm_stat line: " << line << LL_ENDL;
}
}
int status(pclose(pout));
if (status == -1) // pclose() couldn't retrieve rc
{
// Save errno right away.
int pclose_errno(errno);
// The ECHILD error happens so frequently that unless filtered,
// the warning below spams the log file. This is too bad, because
// sometimes the logic above fails to produce any output derived
// from vm_stat, but we've been unable to observe any specific
// error indicating the problem.
if (pclose_errno != ECHILD)
{
LL_WARNS("LLMemoryInfo") << "Unable to obtain vm_stat termination code: ";
char buffer[256];
if (0 == strerror_r(pclose_errno, buffer, sizeof(buffer)))
{
LL_CONT << buffer;
}
else
{
LL_CONT << "errno " << pclose_errno;
}
LL_CONT << LL_ENDL;
}
}
else // pclose() retrieved rc; analyze
{
if (WIFEXITED(status))
{
int rc(WEXITSTATUS(status));
if (rc != 0)
{
LL_WARNS("LLMemoryInfo") << "vm_stat terminated with rc " << rc << LL_ENDL;
}
}
else if (WIFSIGNALED(status))
{
LL_WARNS("LLMemoryInfo") << "vm_stat terminated by signal " << WTERMSIG(status)
<< LL_ENDL;
}
}
}
#elif LL_SOLARIS #elif LL_SOLARIS
U64 phys = 0; U64 phys = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment