summaryrefslogtreecommitdiff
path: root/indra/llwindow/llwindowsdl.cpp
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-06-05 19:08:35 -0700
committerRichard Linden <none@none>2013-06-05 19:08:35 -0700
commit702bd5107a71aa3ac7c779a1e2ff0eaa53161e13 (patch)
treefeca9cc804b88e4f1b78a811ae7af359c67e5455 /indra/llwindow/llwindowsdl.cpp
parent6cf85d1bf3eae2d2d798b756100c048ec2b1c411 (diff)
parente1d96d72692d70f7e16fb93d6ef1d42c89d26409 (diff)
Automated merge with ssh://hg.lindenlab.com/richard/viewer-interesting
Diffstat (limited to 'indra/llwindow/llwindowsdl.cpp')
-rwxr-xr-x[-rw-r--r--]indra/llwindow/llwindowsdl.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index a15114cb9b..205466e936 100644..100755
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -1636,35 +1636,53 @@ void check_vm_bloat()
{
#if LL_LINUX
// watch our own VM and RSS sizes, warn if we bloated rapidly
- FILE *fp = fopen("/proc/self/stat", "r");
+ static const std::string STATS_FILE = "/proc/self/stat";
+ FILE *fp = fopen(STATS_FILE.c_str(), "r");
if (fp)
{
static long long last_vm_size = 0;
static long long last_rss_size = 0;
const long long significant_vm_difference = 250 * 1024*1024;
const long long significant_rss_difference = 50 * 1024*1024;
+ long long this_vm_size = 0;
+ long long this_rss_size = 0;
ssize_t res;
size_t dummy;
- char *ptr;
+ char *ptr = NULL;
for (int i=0; i<22; ++i) // parse past the values we don't want
{
- ptr = NULL;
res = getdelim(&ptr, &dummy, ' ', fp);
+ if (-1 == res)
+ {
+ llwarns << "Unable to parse " << STATS_FILE << llendl;
+ goto finally;
+ }
free(ptr);
+ ptr = NULL;
}
// 23rd space-delimited entry is vsize
- ptr = NULL;
res = getdelim(&ptr, &dummy, ' ', fp);
llassert(ptr);
- long long this_vm_size = atoll(ptr);
+ if (-1 == res)
+ {
+ llwarns << "Unable to parse " << STATS_FILE << llendl;
+ goto finally;
+ }
+ this_vm_size = atoll(ptr);
free(ptr);
- // 24th space-delimited entry is RSS
ptr = NULL;
+ // 24th space-delimited entry is RSS
res = getdelim(&ptr, &dummy, ' ', fp);
llassert(ptr);
- long long this_rss_size = getpagesize() * atoll(ptr);
+ if (-1 == res)
+ {
+ llwarns << "Unable to parse " << STATS_FILE << llendl;
+ goto finally;
+ }
+ this_rss_size = getpagesize() * atoll(ptr);
free(ptr);
+ ptr = NULL;
llinfos << "VM SIZE IS NOW " << (this_vm_size/(1024*1024)) << " MB, RSS SIZE IS NOW " << (this_rss_size/(1024*1024)) << " MB" << llendl;
@@ -1697,6 +1715,12 @@ void check_vm_bloat()
last_rss_size = this_rss_size;
last_vm_size = this_vm_size;
+finally:
+ if (NULL != ptr)
+ {
+ free(ptr);
+ ptr = NULL;
+ }
fclose(fp);
}
#endif // LL_LINUX