summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2014-02-12 18:14:48 -0700
committerXiaohong Bao <bao@lindenlab.com>2014-02-12 18:14:48 -0700
commitf5a63ed31e499903f3d6ff5009d20f980b4fe860 (patch)
tree4234a89e068e7a6780ae9340451c420a7eb594d8 /indra/newview
parentb5389618f3744464760bbe1a54b49750d211a1ac (diff)
reduce peak memory usage to fix SH-4574: Interesting: viewer crash in LLJoint::setScale
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llvocache.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 2176ec9c9c..0f29e9cfa2 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -34,6 +34,7 @@
#include "llviewerregion.h"
#include "pipeline.h"
#include "llagentcamera.h"
+#include "llmemory.h"
//static variables
U32 LLVOCacheEntry::sMinFrameRange = 0;
@@ -381,6 +382,13 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
//static
void LLVOCacheEntry::updateDebugSettings()
{
+ static LLFrameTimer timer;
+ if(timer.getElapsedTimeF32() < 1.0f) //update frequency once per second.
+ {
+ return;
+ }
+ timer.reset();
+
//the number of frames invisible objects stay in memory
static LLCachedControl<U32> inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime");
sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum
@@ -404,6 +412,23 @@ void LLVOCacheEntry::updateDebugSettings()
sRearFarRadius = llmax(rear_max_radius_frac * gAgentCamera.mDrawDistance / 100.f, 1.0f); //minimum value is 1.0m
sRearFarRadius = llmax(sRearFarRadius, (F32)min_radius); //can not be less than "SceneLoadMinRadius".
sRearFarRadius = llmin(sRearFarRadius, gAgentCamera.mDrawDistance); //can not be more than the draw distance.
+
+ //make the above parameters adaptive to memory usage
+ //starts to put restrictions from 750MB, apply tightest restrictions when hits 1GB
+ const U32 low_bound = 750 * 1024; //KB
+ const U32 high_bound = 1024 * 1024; //KB
+
+ LLMemory::updateMemoryInfo() ;
+ U32 allocated_mem = LLMemory::getAllocatedMemKB().value();
+ if(allocated_mem < low_bound)
+ {
+ return;
+ }
+ F32 adjust_factor = llmax(0.f, (F32)(high_bound - allocated_mem) / (high_bound - low_bound));
+
+ sRearFarRadius = llmin(adjust_factor * sRearFarRadius, 96.f); //[0.f, 96.f]
+ sMinFrameRange = (U32)llclamp(adjust_factor * sMinFrameRange, 10.f, 64.f); //[10, 64]
+ sNearRadius = llmax(adjust_factor * sNearRadius, 1.0f);
}
//static