summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-01-04 13:48:35 -0800
committerRichard Linden <none@none>2013-01-04 13:48:35 -0800
commitcbff0e7ab8afeebb6ddab854d35ea12ef9a9930a (patch)
treef99dcc890474f58a967a626ec07b477b1ab37e3d /indra
parentb2197101c488de66ca9ecf71c229f5b80d1390fd (diff)
SH-3468 WIP add memory tracking base class
attempted fix for gcc compile errors can't use typeid() on a class that doesn't have a method defined in a translation unit fix is to force classes deriving from LLMemTrackable to use their own static member named sMemStat
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/lltrace.h27
-rw-r--r--indra/llimage/llimage.cpp1
-rw-r--r--indra/llimage/llimage.h2
-rw-r--r--indra/llui/lltextbase.cpp2
-rw-r--r--indra/llui/lltextbase.h10
-rw-r--r--indra/llui/llview.cpp1
-rw-r--r--indra/llui/llview.h1
-rw-r--r--indra/llui/llviewmodel.cpp2
-rw-r--r--indra/llui/llviewmodel.h2
-rw-r--r--indra/newview/lldrawable.cpp1
-rw-r--r--indra/newview/lldrawable.h1
-rw-r--r--indra/newview/llviewerobject.cpp3
-rw-r--r--indra/newview/llviewerobject.h4
13 files changed, 36 insertions, 21 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index e15cffd7d2..1a156e583e 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -660,13 +660,13 @@ struct MemFootprint<std::list<T> >
}
};
-template<typename T>
+template<typename DERIVED>
class MemTrackable
{
template<typename TRACKED, typename TRACKED_IS_TRACKER>
struct TrackMemImpl;
- typedef MemTrackable<T> mem_trackable_t;
+ typedef MemTrackable<DERIVED> mem_trackable_t;
public:
typedef void mem_trackable_tag_t;
@@ -681,7 +681,7 @@ public:
// reserve 8 bytes for allocation size (and preserving 8 byte alignment of structs)
void* allocation = ::operator new(allocation_size + 8);
*(size_t*)allocation = allocation_size;
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
accumulator->mSize += allocation_size;
@@ -693,7 +693,7 @@ public:
void operator delete(void* ptr)
{
size_t* allocation_size = (size_t*)((char*)ptr - 8);
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
accumulator->mSize -= *allocation_size;
@@ -707,7 +707,7 @@ public:
{
size_t* result = (size_t*)malloc(size + 8);
*result = size;
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
accumulator->mSize += size;
@@ -719,7 +719,7 @@ public:
void operator delete[](void* ptr)
{
size_t* allocation_size = (size_t*)((char*)ptr - 8);
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
accumulator->mSize -= *allocation_size;
@@ -747,7 +747,7 @@ public:
void memClaim(size_t size)
{
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
mMemFootprint += size;
if (accumulator)
{
@@ -772,7 +772,7 @@ public:
void memDisclaim(size_t size)
{
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
accumulator->mSize -= size;
@@ -788,7 +788,7 @@ private:
{
static void claim(mem_trackable_t& tracker, const TRACKED& tracked)
{
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
size_t footprint = MemFootprint<TRACKED>::measure(tracked);
@@ -799,7 +799,7 @@ private:
static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked)
{
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
size_t footprint = MemFootprint<TRACKED>::measure(tracked);
@@ -814,7 +814,7 @@ private:
{
static void claim(mem_trackable_t& tracker, TRACKED& tracked)
{
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
accumulator->mChildSize += MemFootprint<TRACKED>::measure(tracked);
@@ -823,17 +823,14 @@ private:
static void disclaim(mem_trackable_t& tracker, TRACKED& tracked)
{
- MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator();
+ MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
if (accumulator)
{
accumulator->mChildSize -= MemFootprint<TRACKED>::measure(tracked);
}
}
};
- static MemStat sStat;
};
-template<typename T> MemStat MemTrackable<T>::sStat(typeid(T).name());
-
}
#endif // LL_LLTRACE_H
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 22dd809ef3..56f6b0964c 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -50,6 +50,7 @@ LLMutex* LLImage::sMutex = NULL;
bool LLImage::sUseNewByteRange = false;
S32 LLImage::sMinimalReverseByteRangePercent = 75;
LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ;
+LLTrace::MemStat LLImage::sMemStat("LLImage");
//static
void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent)
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index d945d54404..6eafcf1bf7 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -165,6 +165,8 @@ public:
static void destroyPrivatePool() ;
static LLPrivateMemoryPool* getPrivatePool() {return sPrivatePoolp;}
+ static LLTrace::MemStat sMemStat;
+
private:
U8 *mData;
S32 mDataSize;
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 31d67a9e08..74e966560e 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -47,6 +47,8 @@
const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds
const S32 CURSOR_THICKNESS = 2;
+LLTrace::MemStat LLTextSegment::sMemStat("LLTextSegment");
+
LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num)
: mDocIndexStart(index_start),
mDocIndexEnd(index_end),
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 966dd93888..7d791ec75a 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -94,10 +94,12 @@ public:
/*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const;
/*virtual*/ BOOL hasMouseCapture();
- S32 getStart() const { return mStart; }
- void setStart(S32 start) { mStart = start; }
- S32 getEnd() const { return mEnd; }
- void setEnd( S32 end ) { mEnd = end; }
+ S32 getStart() const { return mStart; }
+ void setStart(S32 start) { mStart = start; }
+ S32 getEnd() const { return mEnd; }
+ void setEnd( S32 end ) { mEnd = end; }
+
+ static LLTrace::MemStat sMemStat;
protected:
S32 mStart;
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 59577e95ac..47bf410af6 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -67,6 +67,7 @@ LLView* LLView::sPreviewClickedElement = NULL;
BOOL LLView::sDrawPreviewHighlights = FALSE;
S32 LLView::sLastLeftXML = S32_MIN;
S32 LLView::sLastBottomXML = S32_MIN;
+LLTrace::MemStat LLView::sMemStat("LLView");
std::vector<LLViewDrawContext*> LLViewDrawContext::sDrawContextStack;
LLView::DrilldownFunc LLView::sDrilldown =
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 29ee2125f9..256f86c00d 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -673,6 +673,7 @@ public:
static S32 sLastLeftXML;
static S32 sLastBottomXML;
static BOOL sForceReshape;
+ static LLTrace::MemStat sMemStat;
};
class LLCompareByTabOrder
diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp
index dff0dcb2fd..1bd09e8086 100644
--- a/indra/llui/llviewmodel.cpp
+++ b/indra/llui/llviewmodel.cpp
@@ -35,6 +35,8 @@
// external library headers
// other Linden headers
+LLTrace::MemStat LLViewModel::sMemStat("LLViewModel");
+
///
LLViewModel::LLViewModel()
: mDirty(false)
diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h
index a2ca20c739..214780393b 100644
--- a/indra/llui/llviewmodel.h
+++ b/indra/llui/llviewmodel.h
@@ -83,6 +83,8 @@ public:
//
void setDirty() { mDirty = true; }
+ static LLTrace::MemStat sMemStat;
+
protected:
LLSD mValue;
bool mDirty;
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 09bbafd54a..6ef437cefb 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -58,6 +58,7 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
extern bool gShiftFrame;
+LLTrace::MemStat LLDrawable::sMemStat("LLDrawable");
////////////////////////
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index f15090fb87..abfdea2699 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -314,6 +314,7 @@ public:
LLSpatialBridge* getSpatialBridge() { return (LLSpatialBridge*) (LLDrawable*) mSpatialBridge; }
static F32 sCurPixelAngle; //current pixels per radian
+ static LLTrace::MemStat sMemStat;
private:
typedef std::vector<LLFace*> face_list_t;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index fff1875ad6..ee8bb50e4e 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -112,6 +112,9 @@ BOOL LLViewerObject::sMapDebug = TRUE;
LLColor4 LLViewerObject::sEditSelectColor( 1.0f, 1.f, 0.f, 0.3f); // Edit OK
LLColor4 LLViewerObject::sNoEditSelectColor( 1.0f, 0.f, 0.f, 0.3f); // Can't edit
S32 LLViewerObject::sAxisArrowLength(50);
+LLTrace::MemStat LLViewerObject::sMemStat("LLViewerObject");
+
+
BOOL LLViewerObject::sPulseEnabled(FALSE);
BOOL LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 14ea8ded38..153f44601c 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -670,8 +670,6 @@ protected:
void deleteParticleSource();
void setParticleSource(const LLPartSysData& particle_parameters, const LLUUID& owner_id);
-public:
-
private:
void setNameValueList(const std::string& list); // clears nv pairs and then individually adds \n separated NV pairs from \0 terminated string
void deleteTEImages(); // correctly deletes list of images
@@ -750,6 +748,8 @@ protected:
static S32 sAxisArrowLength;
+ static LLTrace::MemStat sMemStat;
+
// These two caches are only correct for non-parented objects right now!
mutable LLVector3 mPositionRegion;
mutable LLVector3 mPositionAgent;