diff options
author | Richard Linden <none@none> | 2013-10-01 13:46:43 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-10-01 13:46:43 -0700 |
commit | 12f0f8cb72f789e21b01b45063dcc5f1f5292087 (patch) | |
tree | d8777341699dcea574e261da8c982ad22860de13 /indra | |
parent | a96da325564f4e9769e85ad006f98a4ac08d4a47 (diff) |
changed over to manual naming of MemTrackable stats
changed claimMem and disclaimMem behavior to not pass through argument
added more mem tracking stats to floater_stats
Diffstat (limited to 'indra')
33 files changed, 290 insertions, 432 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index da4bf6e36b..226f64d0c7 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -35,6 +35,8 @@ #include "lltraceaccumulators.h" #include "llthreadlocalstorage.h" #include "lltimer.h" +#include "llpointer.h" +#include "llunits.h" #include <list> @@ -206,39 +208,6 @@ public: {} }; -template<> -class TraceType<MemStatAccumulator::ShadowAllocationFacet> - : public TraceType<MemStatAccumulator> -{ -public: - - TraceType(const char* name, const char* description = "") - : TraceType<MemStatAccumulator>(name, description) - {} -}; - -template<> -class TraceType<MemStatAccumulator::ShadowDeallocationFacet> - : public TraceType<MemStatAccumulator> -{ -public: - - TraceType(const char* name, const char* description = "") - : TraceType<MemStatAccumulator>(name, description) - {} -}; - -template<> -class TraceType<MemStatAccumulator::ShadowMemFacet> - : public TraceType<MemStatAccumulator> -{ -public: - - TraceType(const char* name, const char* description = "") - : TraceType<MemStatAccumulator>(name, description) - {} -}; - class MemStatHandle : public TraceType<MemStatAccumulator> { public: @@ -264,109 +233,40 @@ public: { return static_cast<TraceType<MemStatAccumulator::DeallocationFacet>&>(*(TraceType<MemStatAccumulator>*)this); } - - TraceType<MemStatAccumulator::ShadowAllocationFacet>& shadowAllocations() - { - return static_cast<TraceType<MemStatAccumulator::ShadowAllocationFacet>&>(*(TraceType<MemStatAccumulator>*)this); - } - - TraceType<MemStatAccumulator::ShadowDeallocationFacet>& shadowDeallocations() - { - return static_cast<TraceType<MemStatAccumulator::ShadowDeallocationFacet>&>(*(TraceType<MemStatAccumulator>*)this); - } - - TraceType<MemStatAccumulator::ShadowMemFacet>& shadowMem() - { - return static_cast<TraceType<MemStatAccumulator::ShadowMemFacet>&>(*(TraceType<MemStatAccumulator>*)this); - } }; -inline void claim_footprint(MemStatHandle& measurement, S32 size) -{ - if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mFootprintAllocations.record(size); -} - -inline void disclaim_footprint(MemStatHandle& measurement, S32 size) -{ - if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); - accumulator.mFootprintDeallocations.add(size); -} - -inline void claim_shadow(MemStatHandle& measurement, S32 size) -{ - if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); - accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mShadowAllocations.record(size); -} - -inline void disclaim_shadow(MemStatHandle& measurement, S32 size) -{ - if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); - accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); - accumulator.mShadowDeallocations.add(size); -} // measures effective memory footprint of specified type // specialize to cover different types - -template<typename T, typename IS_MEM_TRACKABLE = void> +template<typename T, typename IS_MEM_TRACKABLE = void, typename IS_UNITS = void> struct MeasureMem { static size_t measureFootprint(const T& value) { return sizeof(T); } - - static size_t measureFootprint() - { - return sizeof(T); - } - - static size_t measureShadow(const T& value) - { - return 0; - } - - static size_t measureShadow() - { - return 0; - } }; -template<typename T> -struct MeasureMem<T, typename T::mem_trackable_tag_t> +template<typename T, typename IS_BYTES> +struct MeasureMem<T, typename T::mem_trackable_tag_t, IS_BYTES> { static size_t measureFootprint(const T& value) { return sizeof(T) + value.getMemFootprint(); } +}; - static size_t measureFootprint() - { - return sizeof(T); - } - - static size_t measureShadow(const T& value) - { - return value.getMemShadow(); - } - - static size_t measureShadow() +template<typename T, typename IS_MEM_TRACKABLE> +struct MeasureMem<T, IS_MEM_TRACKABLE, typename T::is_unit_t> +{ + static size_t measureFootprint(const T& value) { - return MeasureMem<T>::measureShadow(); + return U32Bytes(value).value(); } }; - -template<typename T, typename IS_MEM_TRACKABLE> -struct MeasureMem<T*, IS_MEM_TRACKABLE> +template<typename T, typename IS_MEM_TRACKABLE, typename IS_BYTES> +struct MeasureMem<T*, IS_MEM_TRACKABLE, IS_BYTES> { static size_t measureFootprint(const T* value) { @@ -376,46 +276,68 @@ struct MeasureMem<T*, IS_MEM_TRACKABLE> } return MeasureMem<T>::measureFootprint(*value); } +}; - static size_t measureFootprint() +template<typename T, typename IS_MEM_TRACKABLE, typename IS_BYTES> +struct MeasureMem<LLPointer<T>, IS_MEM_TRACKABLE, IS_BYTES> +{ + static size_t measureFootprint(const LLPointer<T> value) { - return MeasureMem<T>::measureFootprint(); + if (value.isNull()) + { + return 0; + } + return MeasureMem<T>::measureFootprint(*value); } +}; - static size_t measureShadow(const T* value) +template<typename IS_MEM_TRACKABLE, typename IS_BYTES> +struct MeasureMem<S32, IS_MEM_TRACKABLE, IS_BYTES> +{ + static size_t measureFootprint(S32 value) { - return MeasureMem<T>::measureShadow(*value); + return value; } +}; - static size_t measureShadow() +template<typename IS_MEM_TRACKABLE, typename IS_BYTES> +struct MeasureMem<U32, IS_MEM_TRACKABLE, IS_BYTES> +{ + static size_t measureFootprint(U32 value) { - return MeasureMem<T>::measureShadow(); + return value; } }; -template<typename T, typename IS_MEM_TRACKABLE> -struct MeasureMem<std::basic_string<T>, IS_MEM_TRACKABLE> +template<typename T, typename IS_MEM_TRACKABLE, typename IS_BYTES> +struct MeasureMem<std::basic_string<T>, IS_MEM_TRACKABLE, IS_BYTES> { static size_t measureFootprint(const std::basic_string<T>& value) { return value.capacity() * sizeof(T); } +}; - static size_t measureFootprint() - { - return sizeof(std::basic_string<T>); - } - static size_t measureShadow(const std::basic_string<T>& value) - { - return 0; - } +template<typename T> +inline void claim_footprint(MemStatHandle& measurement, const T& value) +{ + S32 size = MeasureMem<T>::measureFootprint(value); + if(size == 0) return; + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); + accumulator.mFootprintAllocations.record(size); +} - static size_t measureShadow() - { - return 0; - } -}; +template<typename T> +inline void disclaim_footprint(MemStatHandle& measurement, const T& value) +{ + S32 size = MeasureMem<T>::measureFootprint(value); + if(size == 0) return; + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); + accumulator.mFootprintDeallocations.add(size); +} template<typename DERIVED, size_t ALIGNMENT = LL_DEFAULT_HEAP_ALIGN> class MemTrackable @@ -423,28 +345,20 @@ class MemTrackable public: typedef void mem_trackable_tag_t; - enum EMemType - { - MEM_FOOTPRINT, - MEM_SHADOW - }; - - MemTrackable() - : mMemFootprint(0), - mMemShadow(0) + MemTrackable(const char* name) + : mMemFootprint(0) { static bool name_initialized = false; if (!name_initialized) { name_initialized = true; - sMemStat.setName(typeid(DERIVED).name()); + sMemStat.setName(name); } } virtual ~MemTrackable() { - disclaimMem(mMemFootprint, MEM_FOOTPRINT); - disclaimMem(mMemShadow, MEM_SHADOW); + disclaimMem(mMemFootprint); } static MemStatHandle& getMemStatHandle() @@ -453,7 +367,6 @@ public: } S32 getMemFootprint() const { return mMemFootprint; } - S32 getMemShadow() const { return mMemShadow; } void* operator new(size_t size) { @@ -467,7 +380,7 @@ public: ll_aligned_free(ALIGNMENT, ptr); } - void *operator new [](size_t size) + void* operator new [](size_t size) { claim_footprint(sMemStat, size); return ll_aligned_malloc(ALIGNMENT, size); @@ -481,98 +394,27 @@ public: // claim memory associated with other objects/data as our own, adding to our calculated footprint template<typename CLAIM_T> - CLAIM_T& claimMem(CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT) - { - trackAlloc(MeasureMem<CLAIM_T>::measureFootprint(value), mem_type); - trackAlloc(MeasureMem<CLAIM_T>::measureShadow(value), MEM_SHADOW); - return value; - } - - template<typename CLAIM_T> - const CLAIM_T& claimMem(const CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT) - { - trackAlloc(MeasureMem<CLAIM_T>::measureFootprint(value), mem_type); - trackAlloc(MeasureMem<CLAIM_T>::measureShadow(value), MEM_SHADOW); - return value; - } - - size_t& claimMem(size_t& size, EMemType mem_type = MEM_FOOTPRINT) - { - trackAlloc(size, mem_type); - return size; - } - - S32& claimMem(S32& size, EMemType mem_type = MEM_FOOTPRINT) + void claimMem(const CLAIM_T& value) const { - trackAlloc(size, mem_type); - return size; + S32 size = MeasureMem<CLAIM_T>::measureFootprint(value); + claim_footprint(sMemStat, size); + mMemFootprint += size; } // remove memory we had claimed from our calculated footprint template<typename CLAIM_T> - CLAIM_T& disclaimMem(CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT) - { - trackDealloc(MeasureMem<CLAIM_T>::measureFootprint(value), mem_type); - trackDealloc(MeasureMem<CLAIM_T>::measureShadow(value), MEM_SHADOW); - return value; - } - - template<typename CLAIM_T> - const CLAIM_T& disclaimMem(const CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT) - { - trackDealloc(MeasureMem<CLAIM_T>::measureFootprint(value), mem_type); - trackDealloc(MeasureMem<CLAIM_T>::measureShadow(value), MEM_SHADOW); - return value; - } - - size_t& disclaimMem(size_t& size, EMemType mem_type = MEM_FOOTPRINT) + void disclaimMem(const CLAIM_T& value) const { - trackDealloc(size, mem_type); - return size; - } - - S32& disclaimMem(S32& size, EMemType mem_type = MEM_FOOTPRINT) - { - trackDealloc(size, mem_type); - return size; - } - -private: - - void trackAlloc(S32 size, EMemType mem_type) - { - if (mem_type == MEM_FOOTPRINT) - { - claim_footprint(sMemStat, size); - mMemFootprint += size; - } - else - { - claim_shadow(sMemStat, size); - mMemShadow += size; - } - } - - void trackDealloc(S32 size, EMemType mem_type) - { - if (mem_type == MEM_FOOTPRINT) - { - disclaim_footprint(sMemStat, size); - mMemFootprint -= size; - } - else - { - disclaim_shadow(sMemStat, size); - mMemShadow -= size; - } + S32 size = MeasureMem<CLAIM_T>::measureFootprint(value); + disclaim_footprint(sMemStat, size); + mMemFootprint -= size; } private: // use signed values so that we can temporarily go negative // and reconcile in destructor // NB: this assumes that no single class is responsible for > 2GB of allocations - S32 mMemFootprint, - mMemShadow; + mutable S32 mMemFootprint; static MemStatHandle sMemStat; }; diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index a7bd04415e..f5f2e7df1c 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -125,6 +125,11 @@ void AccumulatorBufferGroup::sync() void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) { + if (append_type == NON_SEQUENTIAL) + { + return; + } + if (!mHasValue) { *this = other; diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 5cba3e5360..ecc569f5d6 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -498,32 +498,14 @@ namespace LLTrace typedef F64Bytes value_t; }; - struct ShadowAllocationFacet - { - typedef F64Bytes value_t; - }; - - struct ShadowDeallocationFacet - { - typedef F64Bytes value_t; - }; - - struct ShadowMemFacet - { - typedef F64Bytes value_t; - }; - void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type) { mFootprintAllocations.addSamples(other.mFootprintAllocations, append_type); mFootprintDeallocations.addSamples(other.mFootprintDeallocations, append_type); - mShadowAllocations.addSamples(other.mShadowAllocations, append_type); - mShadowDeallocations.addSamples(other.mShadowDeallocations, append_type); if (append_type == SEQUENTIAL) { mSize.addSamples(other.mSize, SEQUENTIAL); - mShadowSize.addSamples(other.mShadowSize, SEQUENTIAL); } else { @@ -531,36 +513,24 @@ namespace LLTrace mSize.sample(mSize.hasValue() ? mSize.getLastValue() + allocation_delta : allocation_delta); - - F64 shadow_allocation_delta(other.mShadowAllocations.getSum() - other.mShadowDeallocations.getSum()); - mShadowSize.sample(mShadowSize.hasValue() - ? mShadowSize.getLastValue() + shadow_allocation_delta - : shadow_allocation_delta); } } void reset(const MemStatAccumulator* other) { mSize.reset(other ? &other->mSize : NULL); - mShadowSize.reset(other ? &other->mShadowSize : NULL); mFootprintAllocations.reset(other ? &other->mFootprintAllocations : NULL); mFootprintDeallocations.reset(other ? &other->mFootprintDeallocations : NULL); - mShadowAllocations.reset(other ? &other->mShadowAllocations : NULL); - mShadowDeallocations.reset(other ? &other->mShadowDeallocations : NULL); } void sync(F64SecondsImplicit time_stamp) { mSize.sync(time_stamp); - mShadowSize.sync(time_stamp); } - SampleAccumulator mSize, - mShadowSize; - EventAccumulator mFootprintAllocations, - mShadowAllocations; - CountAccumulator mFootprintDeallocations, - mShadowDeallocations; + SampleAccumulator mSize; + EventAccumulator mFootprintAllocations; + CountAccumulator mFootprintDeallocations; }; struct AccumulatorBufferGroup : public LLRefCount diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index fb2293844a..ce4a433cca 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -173,11 +173,6 @@ bool Recording::hasValue(const TraceType<MemStatAccumulator>& stat) return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } -bool Recording::hasValue(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowSize.hasValue(); -} - F64Kilobytes Recording::getMin(const TraceType<MemStatAccumulator>& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); @@ -203,31 +198,6 @@ F64Kilobytes Recording::getLastValue(const TraceType<MemStatAccumulator>& stat) return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Kilobytes Recording::getMin(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMin()); -} - -F64Kilobytes Recording::getMean(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMean()); -} - -F64Kilobytes Recording::getMax(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMax()); -} - -F64Kilobytes Recording::getStandardDeviation(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getStandardDeviation()); -} - -F64Kilobytes Recording::getLastValue(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getLastValue()); -} - F64Kilobytes Recording::getSum(const TraceType<MemStatAccumulator::AllocationFacet>& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum()); @@ -258,36 +228,6 @@ S32 Recording::getSampleCount(const TraceType<MemStatAccumulator::DeallocationFa return mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSampleCount(); } -F64Kilobytes Recording::getSum(const TraceType<MemStatAccumulator::ShadowAllocationFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum()); -} - -F64Kilobytes Recording::getPerSec(const TraceType<MemStatAccumulator::ShadowAllocationFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum() / mElapsedSeconds.value()); -} - -S32 Recording::getSampleCount(const TraceType<MemStatAccumulator::ShadowAllocationFacet>& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSampleCount(); -} - -F64Kilobytes Recording::getSum(const TraceType<MemStatAccumulator::ShadowDeallocationFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum()); -} - -F64Kilobytes Recording::getPerSec(const TraceType<MemStatAccumulator::ShadowDeallocationFacet>& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum() / mElapsedSeconds.value()); -} - -S32 Recording::getSampleCount(const TraceType<MemStatAccumulator::ShadowDeallocationFacet>& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSampleCount(); -} - F64 Recording::getSum( const TraceType<CountAccumulator>& stat ) { return mBuffers->mCounts[stat.getIndex()].getSum(); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 13dffdc701..085780198d 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -30,7 +30,6 @@ #include "stdtypes.h" #include "llpreprocessor.h" -#include "llpointer.h" #include "lltimer.h" #include "lltraceaccumulators.h" @@ -178,7 +177,6 @@ namespace LLTrace // Memory accessors bool hasValue(const TraceType<MemStatAccumulator>& stat); - bool hasValue(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat); F64Kilobytes getMin(const TraceType<MemStatAccumulator>& stat); F64Kilobytes getMean(const TraceType<MemStatAccumulator>& stat); @@ -186,12 +184,6 @@ namespace LLTrace F64Kilobytes getStandardDeviation(const TraceType<MemStatAccumulator>& stat); F64Kilobytes getLastValue(const TraceType<MemStatAccumulator>& stat); - F64Kilobytes getMin(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat); - F64Kilobytes getMean(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat); - F64Kilobytes getMax(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat); - F64Kilobytes getStandardDeviation(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat); - F64Kilobytes getLastValue(const TraceType<MemStatAccumulator::ShadowMemFacet>& stat); - F64Kilobytes getSum(const TraceType<MemStatAccumulator::AllocationFacet>& stat); F64Kilobytes getPerSec(const TraceType<MemStatAccumulator::AllocationFacet>& stat); S32 getSampleCount(const TraceType<MemStatAccumulator::AllocationFacet>& stat); @@ -200,14 +192,6 @@ namespace LLTrace F64Kilobytes getPerSec(const TraceType<MemStatAccumulator::DeallocationFacet>& stat); S32 getSampleCount(const TraceType<MemStatAccumulator::DeallocationFacet>& stat); - F64Kilobytes getSum(const TraceType<MemStatAccumulator::ShadowAllocationFacet>& stat); - F64Kilobytes getPerSec(const TraceType<MemStatAccumulator::ShadowAllocationFacet>& stat); - S32 getSampleCount(const TraceType<MemStatAccumulator::ShadowAllocationFacet>& stat); - - F64Kilobytes getSum(const TraceType<MemStatAccumulator::ShadowDeallocationFacet>& stat); - F64Kilobytes getPerSec(const TraceType<MemStatAccumulator::ShadowDeallocationFacet>& stat); - S32 getSampleCount(const TraceType<MemStatAccumulator::ShadowDeallocationFacet>& stat); - // CountStatHandle accessors F64 getSum(const TraceType<CountAccumulator>& stat); template <typename T> diff --git a/indra/llcommon/llunittype.h b/indra/llcommon/llunittype.h index fb72d6d8a9..0e05ecd683 100644 --- a/indra/llcommon/llunittype.h +++ b/indra/llcommon/llunittype.h @@ -80,6 +80,7 @@ struct LLUnit { typedef LLUnit<STORAGE_TYPE, UNITS> self_t; typedef STORAGE_TYPE storage_t; + typedef void is_unit_t; // value initialization LL_FORCE_INLINE explicit LLUnit(storage_t value = storage_t()) diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 326f477504..1ca1bf55a6 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -89,15 +89,15 @@ void LLImage::setLastError(const std::string& message) //--------------------------------------------------------------------------- LLImageBase::LLImageBase() - : mData(NULL), - mDataSize(0), - mWidth(0), - mHeight(0), - mComponents(0), - mBadBufferAllocation(false), - mAllowOverSize(false) -{ -} +: LLTrace::MemTrackable<LLImageBase>("LLImage"), + mData(NULL), + mDataSize(0), + mWidth(0), + mHeight(0), + mComponents(0), + mBadBufferAllocation(false), + mAllowOverSize(false) +{} // virtual LLImageBase::~LLImageBase() @@ -158,7 +158,8 @@ void LLImageBase::sanityCheck() void LLImageBase::deleteData() { FREE_MEM(sPrivatePoolp, mData) ; - disclaimMem(mDataSize) = 0; + disclaimMem(mDataSize); + mDataSize = 0; mData = NULL; } @@ -223,7 +224,9 @@ U8* LLImageBase::reallocateData(S32 size) FREE_MEM(sPrivatePoolp, mData) ; } mData = new_datap; - claimMem(disclaimMem(mDataSize) = size); + disclaimMem(mDataSize); + mDataSize = size; + claimMem(mDataSize); return mData; } @@ -1618,7 +1621,9 @@ void LLImageBase::setDataAndSize(U8 *data, S32 size) { ll_assert_aligned(data, 16); mData = data; - claimMem(disclaimMem(mDataSize) = size); + disclaimMem(mDataSize); + mDataSize = size; + claimMem(mDataSize); } //static diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 8e2bcc3f94..7cd59a2983 100755 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -62,6 +62,7 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mAreaUsedForDataSizeCalcs(0) { mImpl = fallbackCreateLLImageJ2CImpl(); + claimMem(mImpl); // Clear data size table for( S32 i = 0; i <= MAX_DISCARD_LEVEL; i++) diff --git a/indra/llimage/llimagejpeg.cpp b/indra/llimage/llimagejpeg.cpp index a25794dab4..e419c77ff2 100755 --- a/indra/llimage/llimagejpeg.cpp +++ b/indra/llimage/llimagejpeg.cpp @@ -32,8 +32,7 @@ jmp_buf LLImageJPEG::sSetjmpBuffer ; LLImageJPEG::LLImageJPEG(S32 quality) - : - LLImageFormatted(IMG_CODEC_JPEG), +: LLImageFormatted(IMG_CODEC_JPEG), mOutputBuffer( NULL ), mOutputBufferSize( 0 ), mEncodeQuality( quality ) // on a scale from 1 to 100 @@ -383,7 +382,9 @@ boolean LLImageJPEG::encodeEmptyOutputBuffer( j_compress_ptr cinfo ) cinfo->dest->next_output_byte = self->mOutputBuffer + self->mOutputBufferSize; cinfo->dest->free_in_buffer = self->mOutputBufferSize; + self->disclaimMem(self->mOutputBufferSize); self->mOutputBufferSize = new_buffer_size; + self->claimMem(new_buffer_size); return TRUE; } @@ -489,7 +490,9 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) // Allocate a temporary buffer big enough to hold the entire compressed image (and then some) // (Note: we make it bigger in emptyOutputBuffer() if we need to) delete[] mOutputBuffer; + disclaimMem(mOutputBufferSize); mOutputBufferSize = getWidth() * getHeight() * getComponents() + 1024; + claimMem(mOutputBufferSize); mOutputBuffer = new U8[ mOutputBufferSize ]; const U8* raw_image_data = NULL; @@ -526,6 +529,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) jpeg_destroy_compress(&cinfo); delete[] mOutputBuffer; mOutputBuffer = NULL; + disclaimMem(mOutputBufferSize); mOutputBufferSize = 0; return FALSE; } @@ -628,6 +632,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) // After finish_compress, we can release the temp output buffer. delete[] mOutputBuffer; mOutputBuffer = NULL; + disclaimMem(mOutputBufferSize); mOutputBufferSize = 0; //////////////////////////////////////// @@ -640,6 +645,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) jpeg_destroy_compress(&cinfo); delete[] mOutputBuffer; mOutputBuffer = NULL; + disclaimMem(mOutputBufferSize); mOutputBufferSize = 0; return FALSE; } diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index d2efda8612..61ba0939bf 100755 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -72,17 +72,20 @@ const LLUUID MAGIC_ID("3c115e51-04f4-523c-9fa6-98aff1034730"); LLInventoryObject::LLInventoryObject(const LLUUID& uuid, const LLUUID& parent_uuid, LLAssetType::EType type, - const std::string& name) : + const std::string& name) +: LLTrace::MemTrackable<LLInventoryObject>("LLInventoryObject"), mUUID(uuid), mParentUUID(parent_uuid), mType(type), mName(name), mCreationDate(0) { + claimMem(mName); correctInventoryName(mName); } -LLInventoryObject::LLInventoryObject() : +LLInventoryObject::LLInventoryObject() +: LLTrace::MemTrackable<LLInventoryObject>("LLInventoryObject"), mType(LLAssetType::AT_NONE), mCreationDate(0) { @@ -97,7 +100,9 @@ void LLInventoryObject::copyObject(const LLInventoryObject* other) mUUID = other->mUUID; mParentUUID = other->mParentUUID; mType = other->mType; + disclaimMem(mName); mName = other->mName; + claimMem(mName); } const LLUUID& LLInventoryObject::getUUID() const @@ -150,7 +155,9 @@ void LLInventoryObject::rename(const std::string& n) correctInventoryName(new_name); if( !new_name.empty() && new_name != mName ) { + disclaimMem(mName); mName = new_name; + claimMem(mName); } } @@ -326,6 +333,8 @@ LLInventoryItem::LLInventoryItem(const LLUUID& uuid, LLStringUtil::replaceNonstandardASCII(mDescription, ' '); LLStringUtil::replaceChar(mDescription, '|', ' '); + claimMem(mDescription); + mPermissions.initMasks(inv_type); } @@ -357,7 +366,9 @@ void LLInventoryItem::copyItem(const LLInventoryItem* other) copyObject(other); mPermissions = other->mPermissions; mAssetUUID = other->mAssetUUID; + disclaimMem(mDescription); mDescription = other->mDescription; + claimMem(mDescription); mSaleInfo = other->mSaleInfo; mInventoryType = other->mInventoryType; mFlags = other->mFlags; @@ -432,7 +443,9 @@ void LLInventoryItem::setDescription(const std::string& d) LLStringUtil::replaceChar(new_desc, '|', ' '); if( new_desc != mDescription ) { + disclaimMem(mDescription); mDescription = new_desc; + claimMem(mDescription); } } @@ -713,7 +726,9 @@ BOOL LLInventoryItem::importFile(LLFILE* fp) valuestr[0] = '\000'; } + disclaimMem(mDescription); mDescription.assign(valuestr); + claimMem(mDescription); LLStringUtil::replaceNonstandardASCII(mDescription, ' '); /* TODO -- ask Ian about this code const char *donkey = mDescription.c_str(); @@ -919,8 +934,10 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) valuestr[0] = '\000'; } + disclaimMem(mDescription); mDescription.assign(valuestr); LLStringUtil::replaceNonstandardASCII(mDescription, ' '); + claimMem(mDescription); /* TODO -- ask Ian about this code const char *donkey = mDescription.c_str(); if (donkey[0] == '|') @@ -1160,8 +1177,10 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd) w = INV_DESC_LABEL; if (sd.has(w)) { + disclaimMem(mDescription); mDescription = sd[w].asString(); LLStringUtil::replaceNonstandardASCII(mDescription, ' '); + claimMem(mDescription); } w = INV_CREATION_DATE_LABEL; if (sd.has(w)) diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h index 47b06af5b8..aa0b4cc24c 100755 --- a/indra/llinventory/llinventory.h +++ b/indra/llinventory/llinventory.h @@ -34,6 +34,7 @@ #include "llsaleinfo.h" #include "llsd.h" #include "lluuid.h" +#include "lltrace.h" class LLMessageSystem; @@ -43,7 +44,7 @@ class LLMessageSystem; // Base class for anything in the user's inventory. Handles the common code // between items and categories. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLInventoryObject : public LLRefCount +class LLInventoryObject : public LLRefCount, public LLTrace::MemTrackable<LLInventoryObject> { public: typedef std::list<LLPointer<LLInventoryObject> > object_list_t; diff --git a/indra/llrender/llfontbitmapcache.cpp b/indra/llrender/llfontbitmapcache.cpp index c985f6b959..f128636ab2 100755 --- a/indra/llrender/llfontbitmapcache.cpp +++ b/indra/llrender/llfontbitmapcache.cpp @@ -29,7 +29,8 @@ #include "llgl.h" #include "llfontbitmapcache.h" -LLFontBitmapCache::LLFontBitmapCache(): +LLFontBitmapCache::LLFontBitmapCache() +: LLTrace::MemTrackable<LLFontBitmapCache>("LLFontBitmapCache"), mNumComponents(0), mBitmapWidth(0), mBitmapHeight(0), @@ -81,6 +82,7 @@ BOOL LLFontBitmapCache::nextOpenPos(S32 width, S32 &pos_x, S32 &pos_y, S32& bitm { // We're out of space in the current image, or no image // has been allocated yet. Make a new one. + mImageRawVec.push_back(new LLImageRaw); mBitmapNum = mImageRawVec.size()-1; LLImageRaw *image_raw = getImageRaw(mBitmapNum); @@ -122,6 +124,9 @@ BOOL LLFontBitmapCache::nextOpenPos(S32 width, S32 &pos_x, S32 &pos_y, S32& bitm image_gl->createGLTexture(0, image_raw); gGL.getTexUnit(0)->bind(image_gl); image_gl->setFilteringOption(LLTexUnit::TFO_POINT); // was setMipFilterNearest(TRUE, TRUE); + + claimMem(image_raw); + claimMem(image_gl); } else { @@ -151,7 +156,20 @@ void LLFontBitmapCache::destroyGL() void LLFontBitmapCache::reset() { + for (std::vector<LLPointer<LLImageRaw> >::iterator it = mImageRawVec.begin(), end_it = mImageRawVec.end(); + it != end_it; + ++it) + { + disclaimMem(**it); + } mImageRawVec.clear(); + + for (std::vector<LLPointer<LLImageGL> >::iterator it = mImageGLVec.begin(), end_it = mImageGLVec.end(); + it != end_it; + ++it) + { + disclaimMem(**it); + } mImageGLVec.clear(); mBitmapWidth = 0; diff --git a/indra/llrender/llfontbitmapcache.h b/indra/llrender/llfontbitmapcache.h index c93b0c7320..75df3a94a7 100755 --- a/indra/llrender/llfontbitmapcache.h +++ b/indra/llrender/llfontbitmapcache.h @@ -28,10 +28,11 @@ #define LL_LLFONTBITMAPCACHE_H #include <vector> +#include "lltrace.h" // Maintain a collection of bitmaps containing rendered glyphs. // Generalizes the single-bitmap logic from LLFontFreetype and LLFontGL. -class LLFontBitmapCache: public LLRefCount +class LLFontBitmapCache : public LLTrace::MemTrackable<LLFontBitmapCache> { public: LLFontBitmapCache(); diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 4cc5b78b63..bde62f89b3 100755 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -101,7 +101,8 @@ LLFontGlyphInfo::LLFontGlyphInfo(U32 index) } LLFontFreetype::LLFontFreetype() -: mFontBitmapCachep(new LLFontBitmapCache), +: LLTrace::MemTrackable<LLFontFreetype>("LLFontFreetype"), + mFontBitmapCachep(new LLFontBitmapCache), mValid(FALSE), mAscender(0.f), mDescender(0.f), @@ -126,7 +127,7 @@ LLFontFreetype::~LLFontFreetype() // Delete glyph info std::for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); - // mFontBitmapCachep will be cleaned up by LLPointer destructor. + delete mFontBitmapCachep; // mFallbackFonts cleaned up by LLPointer destructor } @@ -186,6 +187,8 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v S32 max_char_height = llround(0.5f + (y_max - y_min)); mFontBitmapCachep->init(components, max_char_width, max_char_height); + claimMem(mFontBitmapCachep); + if (!mFTFace->charmap) { @@ -200,6 +203,7 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v } mName = filename; + claimMem(mName); mPointSize = point_size; mStyle = LLFontGL::NORMAL; @@ -476,6 +480,7 @@ void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const } else { + claimMem(gi); mCharGlyphInfoMap[wch] = gi; } } @@ -517,8 +522,15 @@ void LLFontFreetype::reset(F32 vert_dpi, F32 horz_dpi) void LLFontFreetype::resetBitmapCache() { - for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); + for (char_glyph_info_map_t::iterator it = mCharGlyphInfoMap.begin(), end_it = mCharGlyphInfoMap.end(); + it != end_it; + ++it) + { + disclaimMem(it->second); + delete it->second; + } mCharGlyphInfoMap.clear(); + disclaimMem(mFontBitmapCachep); mFontBitmapCachep->reset(); // Adding default glyph is skipped for fallback fonts here as well as in loadFace(). @@ -540,7 +552,7 @@ const std::string &LLFontFreetype::getName() const return mName; } -const LLPointer<LLFontBitmapCache> LLFontFreetype::getFontBitmapCache() const +const LLFontBitmapCache* LLFontFreetype::getFontBitmapCache() const { return mFontBitmapCachep; } diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index f1b23f22d5..2963fbd43d 100755 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -74,7 +74,7 @@ struct LLFontGlyphInfo extern LLFontManager *gFontManagerp; -class LLFontFreetype : public LLRefCount +class LLFontFreetype : public LLRefCount, public LLTrace::MemTrackable<LLFontFreetype> { public: LLFontFreetype(); @@ -134,7 +134,7 @@ public: const std::string& getName() const; - const LLPointer<LLFontBitmapCache> getFontBitmapCache() const; + const LLFontBitmapCache* getFontBitmapCache() const; void setStyle(U8 style); U8 getStyle() const; @@ -167,7 +167,7 @@ private: typedef boost::unordered_map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t; mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap - mutable LLPointer<LLFontBitmapCache> mFontBitmapCachep; + mutable LLFontBitmapCache* mFontBitmapCachep; mutable S32 mRenderGlyphCount; mutable S32 mAddGlyphCount; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index d66b6d8432..4330a9891e 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -279,8 +279,10 @@ void LLImageGL::destroyGL(BOOL save_state) if (save_state && glimage->isGLTextureCreated() && glimage->mComponents) { glimage->mSaveData = new LLImageRaw; + glimage->claimMem(glimage->mSaveData); if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it. { + glimage->disclaimMem(glimage->mSaveData); glimage->mSaveData = NULL ; } } @@ -354,7 +356,8 @@ BOOL LLImageGL::create(LLPointer<LLImageGL>& dest, const LLImageRaw* imageraw, B //---------------------------------------------------------------------------- LLImageGL::LLImageGL(BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { init(usemipmaps); setSize(0, 0, 0); @@ -363,7 +366,8 @@ LLImageGL::LLImageGL(BOOL usemipmaps) } LLImageGL::LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { llassert( components <= 4 ); init(usemipmaps); @@ -373,7 +377,8 @@ LLImageGL::LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps) } LLImageGL::LLImageGL(const LLImageRaw* imageraw, BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { init(usemipmaps); setSize(0, 0, 0); @@ -387,6 +392,7 @@ LLImageGL::~LLImageGL() { LLImageGL::cleanup(); sImageList.erase(this); + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; sCount--; @@ -500,6 +506,7 @@ void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents, S32 discard_leve } // pickmask validity depends on old image size, delete it + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; mPickMaskWidth = mPickMaskHeight = 0; @@ -1460,7 +1467,9 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ stop_glerror(); } + disclaimMem(mTextureMemory); mTextureMemory = (S32Bytes)getMipBytes(discard_level); + claimMem(mTextureMemory); sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight() ; @@ -1621,6 +1630,7 @@ void LLImageGL::destroyGLTexture() if(mTextureMemory != S32Bytes(0)) { sGlobalTextureMemory -= mTextureMemory; + disclaimMem(mTextureMemory); mTextureMemory = (S32Bytes)0; } @@ -1970,6 +1980,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) return ; } + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; mPickMaskWidth = mPickMaskHeight = 0; @@ -1987,6 +1998,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) U32 size = pick_width * pick_height; size = (size + 7) / 8; // pixelcount-to-bits mPickMask = new U8[size]; + claimMem(size); mPickMaskWidth = pick_width - 1; mPickMaskHeight = pick_height - 1; diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 09ea8a1124..816169a30c 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -42,7 +42,7 @@ class LLTextureAtlas ; #define MEGA_BYTES_TO_BYTES(x) ((x) << 20) //============================================================================ -class LLImageGL : public LLRefCount +class LLImageGL : public LLRefCount, public LLTrace::MemTrackable<LLImageGL> { friend class LLTexUnit; public: diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index b1a5a194be..38351dd9ae 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -959,7 +959,8 @@ S32 LLVertexBuffer::determineUsage(S32 usage) return ret_usage; } -LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : +LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) +: LLTrace::MemTrackable<LLVertexBuffer>("LLVertexBuffer"), LLRefCount(), mNumVerts(0), @@ -1096,7 +1097,9 @@ void LLVertexBuffer::waitFence() const void LLVertexBuffer::genBuffer(U32 size) { + disclaimMem(mSize); mSize = vbo_block_size(size); + claimMem(mSize); if (mUsage == GL_STREAM_DRAW_ARB) { @@ -1185,7 +1188,9 @@ void LLVertexBuffer::createGLBuffer(U32 size) static int gl_buffer_idx = 0; mGLBuffer = ++gl_buffer_idx; mMappedData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); + disclaimMem(mSize); mSize = size; + disclaimMem(mSize); } } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 0b4b87f338..92ea3bfc8e 100755 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -34,6 +34,7 @@ #include "v4coloru.h" #include "llstrider.h" #include "llrender.h" +#include "lltrace.h" #include <set> #include <vector> #include <list> @@ -98,7 +99,7 @@ public: //============================================================================ // base class class LLPrivateMemoryPool; -class LLVertexBuffer : public LLRefCount +class LLVertexBuffer : public LLRefCount, public LLTrace::MemTrackable<LLVertexBuffer> { public: class MappedRegion @@ -112,7 +113,8 @@ public: }; LLVertexBuffer(const LLVertexBuffer& rhs) - : mUsage(rhs.mUsage) + : LLTrace::MemTrackable<LLVertexBuffer>("LLVertexBuffer"), + mUsage(rhs.mUsage) { *this = rhs; } diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 802cb783ed..ac36cd1173 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -1496,16 +1496,12 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item ) ft = std::find(mFolders.begin(), mFolders.end(), f); if (ft != mFolders.end()) { - disclaimMem(mFolders); mFolders.erase(ft); - claimMem(mFolders); } } else { - disclaimMem(mItems); mItems.erase(it); - claimMem(mItems); } //item has been removed, need to update filter getViewModelItem()->removeChild(item->getViewModelItem()); @@ -1582,9 +1578,7 @@ void LLFolderViewFolder::addItem(LLFolderViewItem* item) } item->setParentFolder(this); - disclaimMem(mItems); mItems.push_back(item); - claimMem(mItems); item->setRect(LLRect(0, 0, getRect().getWidth(), 0)); item->setVisible(FALSE); @@ -1607,9 +1601,7 @@ void LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) folder->mParentFolder->extractItem(folder); } folder->mParentFolder = this; - disclaimMem(mFolders); mFolders.push_back(folder); - claimMem(mFolders); folder->setOrigin(0, 0); folder->reshape(getRect().getWidth(), 0); folder->setVisible(FALSE); diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 3f62d133e4..c665dce509 100755 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -111,6 +111,10 @@ public: class LLFolderViewModelInterface : public LLTrace::MemTrackable<LLFolderViewModelInterface> { public: + LLFolderViewModelInterface() + : LLTrace::MemTrackable<LLFolderViewModelInterface>("LLFolderViewModelInterface") + {} + virtual ~LLFolderViewModelInterface() {} virtual void requestSortAll() = 0; @@ -131,7 +135,10 @@ public: class LLFolderViewModelItem : public LLRefCount, public LLTrace::MemTrackable<LLFolderViewModelItem> { public: - LLFolderViewModelItem() { } + LLFolderViewModelItem() + : LLTrace::MemTrackable<LLFolderViewModelItem>("LLFolderViewModelItem") + {} + virtual ~LLFolderViewModelItem() { } virtual void update() {} //called when drawing diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 5c221edea7..730c3b2ada 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -576,7 +576,7 @@ void LLTextBase::drawText() if ( (mSpellCheckStart != start) || (mSpellCheckEnd != end) ) { const LLWString& wstrText = getWText(); - disclaimMem(mMisspellRanges).clear(); + mMisspellRanges.clear(); segment_set_t::const_iterator seg_it = getSegIterContaining(start); while (mSegments.end() != seg_it) @@ -652,7 +652,6 @@ void LLTextBase::drawText() mSpellCheckStart = start; mSpellCheckEnd = end; - claimMem(mMisspellRanges); } } else @@ -922,11 +921,9 @@ void LLTextBase::createDefaultSegment() if (mSegments.empty()) { LLStyleConstSP sp(new LLStyle(getStyleParams())); - disclaimMem(mSegments); LLTextSegmentPtr default_segment = new LLNormalTextSegment( sp, 0, getLength() + 1, *this); mSegments.insert(default_segment); default_segment->linkToDocument(this); - claimMem(mSegments); } } @@ -937,8 +934,6 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert) return; } - disclaimMem(mSegments); - segment_set_t::iterator cur_seg_iter = getSegIterContaining(segment_to_insert->getStart()); S32 reflow_start_index = 0; @@ -1011,7 +1006,6 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert) // layout potentially changed needsReflow(reflow_start_index); - claimMem(mSegments); } BOOL LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask) @@ -1322,10 +1316,8 @@ void LLTextBase::replaceWithSuggestion(U32 index) removeStringNoUndo(it->first, it->second - it->first); // Insert the suggestion in its place - disclaimMem(mSuggestionList); LLWString suggestion = utf8str_to_wstring(mSuggestionList[index]); insertStringNoUndo(it->first, utf8str_to_wstring(mSuggestionList[index])); - claimMem(mSuggestionList); setCursorPos(it->first + (S32)suggestion.length()); @@ -1388,7 +1380,7 @@ bool LLTextBase::isMisspelledWord(U32 pos) const void LLTextBase::onSpellCheckSettingsChange() { // Recheck the spelling on every change - disclaimMem(mMisspellRanges).clear(); + mMisspellRanges.clear(); mSpellCheckStart = mSpellCheckEnd = -1; } @@ -1666,7 +1658,7 @@ LLRect LLTextBase::getTextBoundingRect() void LLTextBase::clearSegments() { - disclaimMem(mSegments).clear(); + mSegments.clear(); createDefaultSegment(); } @@ -3210,9 +3202,7 @@ void LLNormalTextSegment::setToolTip(const std::string& tooltip) LL_WARNS() << "LLTextSegment::setToolTip: cannot replace keyword tooltip." << LL_ENDL; return; } - disclaimMem(mTooltip); mTooltip = tooltip; - claimMem(mTooltip); } bool LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index b1558a7abe..87f1a10cc5 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -53,11 +53,13 @@ class LLUrlMatch; /// class LLTextSegment : public LLRefCount, - public LLMouseHandler, - public LLTrace::MemTrackable<LLTextSegment> + public LLMouseHandler { public: - LLTextSegment(S32 start, S32 end) : mStart(start), mEnd(end){}; + LLTextSegment(S32 start, S32 end) + : mStart(start), + mEnd(end) + {} virtual ~LLTextSegment(); virtual bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 9a81c91e0d..546cd6fc46 100755 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -941,7 +941,9 @@ boost::signals2::connection LLUICtrl::setCommitCallback( boost::function<void (L } boost::signals2::connection LLUICtrl::setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb ) { - if (!mValidateSignal) mValidateSignal = claimMem(new enable_signal_t()); + if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + claimMem(mValidateSignal); + return mValidateSignal->connect(boost::bind(cb, _2)); } @@ -1004,55 +1006,73 @@ boost::signals2::connection LLUICtrl::setValidateCallback(const EnableCallbackPa boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb ) { - if (!mCommitSignal) mCommitSignal = claimMem(new commit_signal_t()); + if (!mCommitSignal) mCommitSignal = new commit_signal_t(); + claimMem(mCommitSignal); + return mCommitSignal->connect(cb); } boost::signals2::connection LLUICtrl::setValidateCallback( const enable_signal_t::slot_type& cb ) { - if (!mValidateSignal) mValidateSignal = claimMem(new enable_signal_t()); + if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + claimMem(mValidateSignal); + return mValidateSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { - if (!mMouseEnterSignal) mMouseEnterSignal = claimMem(new commit_signal_t()); + if (!mMouseEnterSignal) mMouseEnterSignal = new commit_signal_t(); + claimMem(mMouseEnterSignal); + return mMouseEnterSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { - if (!mMouseLeaveSignal) mMouseLeaveSignal = claimMem(new commit_signal_t()); + if (!mMouseLeaveSignal) mMouseLeaveSignal = new commit_signal_t(); + claimMem(mMouseLeaveSignal); + return mMouseLeaveSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseDownCallback( const mouse_signal_t::slot_type& cb ) { - if (!mMouseDownSignal) mMouseDownSignal = claimMem(new mouse_signal_t()); + if (!mMouseDownSignal) mMouseDownSignal = new mouse_signal_t(); + claimMem(mMouseDownSignal); + return mMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseUpCallback( const mouse_signal_t::slot_type& cb ) { - if (!mMouseUpSignal) mMouseUpSignal = claimMem(new mouse_signal_t()); + if (!mMouseUpSignal) mMouseUpSignal = new mouse_signal_t(); + claimMem(mMouseUpSignal); + return mMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ) { - if (!mRightMouseDownSignal) mRightMouseDownSignal = claimMem(new mouse_signal_t()); + if (!mRightMouseDownSignal) mRightMouseDownSignal = new mouse_signal_t(); + claimMem(mRightMouseDownSignal); + return mRightMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ) { - if (!mRightMouseUpSignal) mRightMouseUpSignal = claimMem(new mouse_signal_t()); + if (!mRightMouseUpSignal) mRightMouseUpSignal = new mouse_signal_t(); + claimMem(mRightMouseUpSignal); + return mRightMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setDoubleClickCallback( const mouse_signal_t::slot_type& cb ) { - if (!mDoubleClickSignal) mDoubleClickSignal = claimMem(new mouse_signal_t()); + if (!mDoubleClickSignal) mDoubleClickSignal = new mouse_signal_t(); + claimMem(mDoubleClickSignal); + return mDoubleClickSignal->connect(cb); } diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index e81d19ae3a..e3b3444a00 100755 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -131,7 +131,8 @@ LLView::Params::Params() } LLView::LLView(const LLView::Params& p) -: mVisible(p.visible), +: LLTrace::MemTrackable<LLView>("LLView"), + mVisible(p.visible), mInDraw(false), mName(p.name), mParentView(NULL), diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 3a0dfb5f42..665aad70cf 100755 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -167,7 +167,7 @@ protected: private: // widgets in general are not copyable - LLView(const LLView& other) {}; + LLView(const LLView& other); public: //#if LL_DEBUG static BOOL sIsDrawing; diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index 6459ade027..282addf692 100755 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -37,13 +37,15 @@ /// LLViewModel::LLViewModel() - : mDirty(false) +: LLTrace::MemTrackable<LLViewModel>("LLViewModel"), + mDirty(false) { } /// Instantiate an LLViewModel with an existing data value LLViewModel::LLViewModel(const LLSD& value) - : mDirty(false) +: LLTrace::MemTrackable<LLViewModel>("LLViewModel"), + mDirty(false) { setValue(value); } @@ -79,12 +81,14 @@ LLTextViewModel::LLTextViewModel(const LLSD& value) /// Update the stored value void LLTextViewModel::setValue(const LLSD& value) { - LLViewModel::setValue(value); // approximate LLSD storage usage disclaimMem(mDisplay.size()); + LLViewModel::setValue(value); disclaimMem(mDisplay); mDisplay = utf8str_to_wstring(value.asString()); + claimMem(mDisplay); + // approximate LLSD storage usage claimMem(mDisplay.size()); // mDisplay and mValue agree diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 5baebab5a3..2890d3f61c 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -90,8 +90,9 @@ void LLDrawable::incrementVisible() } LLDrawable::LLDrawable(LLViewerObject *vobj, bool new_entry) - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLDRAWABLE), - mVObjp(vobj) +: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLDRAWABLE), + LLTrace::MemTrackable<LLDrawable, 16>("LLDrawable"), + mVObjp(vobj) { init(new_entry); } diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index a0ac417b24..067cee6838 100755 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -64,7 +64,9 @@ class LLDrawable public LLTrace::MemTrackable<LLDrawable, 16> { public: - LLDrawable(const LLDrawable& rhs) : LLViewerOctreeEntryData(rhs) + LLDrawable(const LLDrawable& rhs) + : LLTrace::MemTrackable<LLDrawable, 16>("LLDrawable"), + LLViewerOctreeEntryData(rhs) { *this = rhs; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 394b11b759..e65f99c452 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -206,7 +206,8 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco } LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp, BOOL is_global) -: LLPrimitive(), +: LLTrace::MemTrackable<LLViewerObject>("LLViewerObject"), + LLPrimitive(), mChildList(), mID(id), mLocalID(0), diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 34b0f450ab..ecb1fd696a 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -287,6 +287,8 @@ public: // LLDebugText // +static LLTrace::TimeBlock FTM_DISPLAY_DEBUG_TEXT("Display Debug Text"); + class LLDebugText { private: @@ -799,6 +801,7 @@ public: void draw() { + LL_RECORD_BLOCK_TIME(FTM_DISPLAY_DEBUG_TEXT); for (line_list_t::iterator iter = mLineList.begin(); iter != mLineList.end(); ++iter) { diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 7ba0c31ffc..01666778b1 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -56,7 +56,8 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes) //--------------------------------------------------------------------------- LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp) - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable<LLVOCacheEntry, 16>("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(local_id), mCRC(crc), mUpdateFlags(-1), @@ -74,7 +75,8 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & } LLVOCacheEntry::LLVOCacheEntry() - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable<LLVOCacheEntry, 16>("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(0), mCRC(0), mUpdateFlags(-1), @@ -91,7 +93,8 @@ LLVOCacheEntry::LLVOCacheEntry() } LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable<LLVOCacheEntry, 16>("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mBuffer(NULL), mUpdateFlags(-1), mState(INACTIVE), @@ -471,6 +474,7 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) //LLVOCachePartition //------------------------------------------------------------------- LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) +: LLTrace::MemTrackable<LLVOCachePartition>("LLVOCachePartition") { mLODPeriod = 16; mRegionp = regionp; diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml index f0a464dfc9..d4decf383d 100755 --- a/indra/newview/skins/default/xui/en/floater_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_stats.xml @@ -111,25 +111,32 @@ <stat_view name="memory" label="Memory Usage"> <stat_bar name="LLView" - label="LLView Memory" - stat="class LLView" - show_history="true"/> + label="UI" + stat="LLView"/> + <stat_bar name="LLFontFreetype" + label="Fonts" + stat="LLFontFreetype"/> + <stat_bar name="LLInventoryObject" + label="Inventory" + stat="LLInventoryObject"/> <stat_bar name="LLViewerObject" - label="LLViewerObject Memory" - stat="class LLViewerObject" - show_history="true"/> + label="Viewer Objects" + stat="LLViewerObject"/> <stat_bar name="LLVOCacheEntry" - label="LLVOCacheEntry Memory" - stat="class LLVOCacheEntry" - show_history="true"/> + label="Viewer Object Cache" + stat="LLVOCacheEntry"/> <stat_bar name="LLDrawable" - label="LLDrawable Memory" - stat="class LLDrawable" - show_history="true"/> + label="Drawables" + stat="LLDrawable"/> <stat_bar name="LLImage" - label="LLImage Memory" - stat="class LLImageBase" - show_history="true"/> + label="Image Data" + stat="LLImage"/> + <stat_bar name="LLImageGL" + label="GL Image Data" + stat="LLImageGL"/> + <stat_bar name="LLVertexBuffer" + label="Vertex Buffers" + stat="LLVertexBuffer"/> </stat_view> <stat_view name="network" label="Network" |