summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermemleak.cpp
diff options
context:
space:
mode:
authorBrad Linden <brad@lindenlab.com>2024-05-23 11:31:19 -0700
committerBrad Linden <brad@lindenlab.com>2024-05-23 11:31:19 -0700
commita1f49564d670a2c41bfa25c833bba2564b9b7f48 (patch)
tree1d205e51bc37621916a17d459ad83782fe41f975 /indra/newview/llfloatermemleak.cpp
parent6af5db09faf5ea33a2d4c47b64e76f42edae178a (diff)
parent6377610f6587989c126b00f490dfc8d527a1c2ce (diff)
Merge remote-tracking branch 'origin/DRTVWR-600-maint-A' into brad/merge-maint-a-to-dev
Diffstat (limited to 'indra/newview/llfloatermemleak.cpp')
-rw-r--r--indra/newview/llfloatermemleak.cpp272
1 files changed, 136 insertions, 136 deletions
diff --git a/indra/newview/llfloatermemleak.cpp b/indra/newview/llfloatermemleak.cpp
index 327de5e2c3..cd5bea1be4 100644
--- a/indra/newview/llfloatermemleak.cpp
+++ b/indra/newview/llfloatermemleak.cpp
@@ -1,25 +1,25 @@
-/**
+/**
* @file llfloatermemleak.cpp
* @brief LLFloatermemleak class definition
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -45,186 +45,186 @@ bool LLFloaterMemLeak::sbAllocationFailed = false ;
extern bool gSimulateMemLeak;
LLFloaterMemLeak::LLFloaterMemLeak(const LLSD& key)
- : LLFloater(key)
+ : LLFloater(key)
{
- setTitle("Memory Leaking Simulation Floater");
- mCommitCallbackRegistrar.add("MemLeak.ChangeLeakingSpeed", boost::bind(&LLFloaterMemLeak::onChangeLeakingSpeed, this));
- mCommitCallbackRegistrar.add("MemLeak.ChangeMaxMemLeaking", boost::bind(&LLFloaterMemLeak::onChangeMaxMemLeaking, this));
- mCommitCallbackRegistrar.add("MemLeak.Start", boost::bind(&LLFloaterMemLeak::onClickStart, this));
- mCommitCallbackRegistrar.add("MemLeak.Stop", boost::bind(&LLFloaterMemLeak::onClickStop, this));
- mCommitCallbackRegistrar.add("MemLeak.Release", boost::bind(&LLFloaterMemLeak::onClickRelease, this));
- mCommitCallbackRegistrar.add("MemLeak.Close", boost::bind(&LLFloaterMemLeak::onClickClose, this));
+ setTitle("Memory Leaking Simulation Floater");
+ mCommitCallbackRegistrar.add("MemLeak.ChangeLeakingSpeed", boost::bind(&LLFloaterMemLeak::onChangeLeakingSpeed, this));
+ mCommitCallbackRegistrar.add("MemLeak.ChangeMaxMemLeaking", boost::bind(&LLFloaterMemLeak::onChangeMaxMemLeaking, this));
+ mCommitCallbackRegistrar.add("MemLeak.Start", boost::bind(&LLFloaterMemLeak::onClickStart, this));
+ mCommitCallbackRegistrar.add("MemLeak.Stop", boost::bind(&LLFloaterMemLeak::onClickStop, this));
+ mCommitCallbackRegistrar.add("MemLeak.Release", boost::bind(&LLFloaterMemLeak::onClickRelease, this));
+ mCommitCallbackRegistrar.add("MemLeak.Close", boost::bind(&LLFloaterMemLeak::onClickClose, this));
}
//----------------------------------------------
bool LLFloaterMemLeak::postBuild(void)
-{
- F32 a, b ;
- a = getChild<LLUICtrl>("leak_speed")->getValue().asReal();
- if(a > (F32)(0xFFFFFFFF))
- {
- sMemLeakingSpeed = 0xFFFFFFFF ;
- }
- else
- {
- sMemLeakingSpeed = (U32)a ;
- }
- b = getChild<LLUICtrl>("max_leak")->getValue().asReal();
- if(b > (F32)0xFFF)
- {
- sMaxLeakedMem = 0xFFFFFFFF ;
- }
- else
- {
- sMaxLeakedMem = ((U32)b) << 20 ;
- }
-
- sbAllocationFailed = false ;
- return true ;
+{
+ F32 a, b ;
+ a = getChild<LLUICtrl>("leak_speed")->getValue().asReal();
+ if(a > (F32)(0xFFFFFFFF))
+ {
+ sMemLeakingSpeed = 0xFFFFFFFF ;
+ }
+ else
+ {
+ sMemLeakingSpeed = (U32)a ;
+ }
+ b = getChild<LLUICtrl>("max_leak")->getValue().asReal();
+ if(b > (F32)0xFFF)
+ {
+ sMaxLeakedMem = 0xFFFFFFFF ;
+ }
+ else
+ {
+ sMaxLeakedMem = ((U32)b) << 20 ;
+ }
+
+ sbAllocationFailed = false ;
+ return true ;
}
LLFloaterMemLeak::~LLFloaterMemLeak()
{
- release() ;
-
- sMemLeakingSpeed = 0 ; //bytes leaked per frame
- sMaxLeakedMem = 0 ; //maximum allowed leaked memory
+ release() ;
+
+ sMemLeakingSpeed = 0 ; //bytes leaked per frame
+ sMaxLeakedMem = 0 ; //maximum allowed leaked memory
}
void LLFloaterMemLeak::release()
{
- if(mLeakedMem.empty())
- {
- return ;
- }
-
- for(S32 i = 0 ; i < (S32)mLeakedMem.size() ; i++)
- {
- delete[] mLeakedMem[i] ;
- }
- mLeakedMem.clear() ;
-
- sStatus = STOP ;
- sTotalLeaked = 0 ;
- sbAllocationFailed = false ;
- gSimulateMemLeak = false;
+ if(mLeakedMem.empty())
+ {
+ return ;
+ }
+
+ for(S32 i = 0 ; i < (S32)mLeakedMem.size() ; i++)
+ {
+ delete[] mLeakedMem[i] ;
+ }
+ mLeakedMem.clear() ;
+
+ sStatus = STOP ;
+ sTotalLeaked = 0 ;
+ sbAllocationFailed = false ;
+ gSimulateMemLeak = false;
}
void LLFloaterMemLeak::stop()
{
- sStatus = STOP ;
- sbAllocationFailed = true ;
+ sStatus = STOP ;
+ sbAllocationFailed = true ;
}
void LLFloaterMemLeak::idle()
{
- if(STOP == sStatus)
- {
- return ;
- }
-
- sbAllocationFailed = false ;
-
- if(RELEASE == sStatus)
- {
- release() ;
- return ;
- }
-
- char* p = NULL ;
- if(sMemLeakingSpeed > 0 && sTotalLeaked < sMaxLeakedMem)
- {
- p = new char[sMemLeakingSpeed] ;
-
- if(p)
- {
- mLeakedMem.push_back(p) ;
- sTotalLeaked += sMemLeakingSpeed ;
- }
- }
- if(!p)
- {
- stop();
- }
+ if(STOP == sStatus)
+ {
+ return ;
+ }
+
+ sbAllocationFailed = false ;
+
+ if(RELEASE == sStatus)
+ {
+ release() ;
+ return ;
+ }
+
+ char* p = NULL ;
+ if(sMemLeakingSpeed > 0 && sTotalLeaked < sMaxLeakedMem)
+ {
+ p = new char[sMemLeakingSpeed] ;
+
+ if(p)
+ {
+ mLeakedMem.push_back(p) ;
+ sTotalLeaked += sMemLeakingSpeed ;
+ }
+ }
+ if(!p)
+ {
+ stop();
+ }
}
//----------------------
void LLFloaterMemLeak::onChangeLeakingSpeed()
{
- F32 tmp ;
- tmp =getChild<LLUICtrl>("leak_speed")->getValue().asReal();
-
- if(tmp > (F32)0xFFFFFFFF)
- {
- sMemLeakingSpeed = 0xFFFFFFFF ;
- }
- else
- {
- sMemLeakingSpeed = (U32)tmp ;
- }
+ F32 tmp ;
+ tmp =getChild<LLUICtrl>("leak_speed")->getValue().asReal();
+
+ if(tmp > (F32)0xFFFFFFFF)
+ {
+ sMemLeakingSpeed = 0xFFFFFFFF ;
+ }
+ else
+ {
+ sMemLeakingSpeed = (U32)tmp ;
+ }
}
void LLFloaterMemLeak::onChangeMaxMemLeaking()
{
- F32 tmp ;
- tmp =getChild<LLUICtrl>("max_leak")->getValue().asReal();
- if(tmp > (F32)0xFFF)
- {
- sMaxLeakedMem = 0xFFFFFFFF ;
- }
- else
- {
- sMaxLeakedMem = ((U32)tmp) << 20 ;
- }
-
+ F32 tmp ;
+ tmp =getChild<LLUICtrl>("max_leak")->getValue().asReal();
+ if(tmp > (F32)0xFFF)
+ {
+ sMaxLeakedMem = 0xFFFFFFFF ;
+ }
+ else
+ {
+ sMaxLeakedMem = ((U32)tmp) << 20 ;
+ }
+
}
void LLFloaterMemLeak::onClickStart()
{
- sStatus = START ;
- gSimulateMemLeak = true;
+ sStatus = START ;
+ gSimulateMemLeak = true;
}
void LLFloaterMemLeak::onClickStop()
{
- sStatus = STOP ;
+ sStatus = STOP ;
}
void LLFloaterMemLeak::onClickRelease()
{
- sStatus = RELEASE ;
+ sStatus = RELEASE ;
}
void LLFloaterMemLeak::onClickClose()
{
- setVisible(false);
+ setVisible(false);
}
void LLFloaterMemLeak::draw()
{
- //show total memory leaked
- if(sTotalLeaked > 0)
- {
- std::string bytes_string;
- LLResMgr::getInstance()->getIntegerString(bytes_string, sTotalLeaked >> 10 );
- getChild<LLUICtrl>("total_leaked_label")->setTextArg("[SIZE]", bytes_string);
- }
- else
- {
- getChild<LLUICtrl>("total_leaked_label")->setTextArg("[SIZE]", LLStringExplicit("0"));
- }
-
- if(sbAllocationFailed)
- {
- getChild<LLUICtrl>("note_label_1")->setTextArg("[NOTE1]", LLStringExplicit("Memory leaking simulation stops. Reduce leaking speed or"));
- getChild<LLUICtrl>("note_label_2")->setTextArg("[NOTE2]", LLStringExplicit("increase max leaked memory, then press Start to continue."));
- }
- else
- {
- getChild<LLUICtrl>("note_label_1")->setTextArg("[NOTE1]", LLStringExplicit(""));
- getChild<LLUICtrl>("note_label_2")->setTextArg("[NOTE2]", LLStringExplicit(""));
- }
-
- LLFloater::draw();
+ //show total memory leaked
+ if(sTotalLeaked > 0)
+ {
+ std::string bytes_string;
+ LLResMgr::getInstance()->getIntegerString(bytes_string, sTotalLeaked >> 10 );
+ getChild<LLUICtrl>("total_leaked_label")->setTextArg("[SIZE]", bytes_string);
+ }
+ else
+ {
+ getChild<LLUICtrl>("total_leaked_label")->setTextArg("[SIZE]", LLStringExplicit("0"));
+ }
+
+ if(sbAllocationFailed)
+ {
+ getChild<LLUICtrl>("note_label_1")->setTextArg("[NOTE1]", LLStringExplicit("Memory leaking simulation stops. Reduce leaking speed or"));
+ getChild<LLUICtrl>("note_label_2")->setTextArg("[NOTE2]", LLStringExplicit("increase max leaked memory, then press Start to continue."));
+ }
+ else
+ {
+ getChild<LLUICtrl>("note_label_1")->setTextArg("[NOTE1]", LLStringExplicit(""));
+ getChild<LLUICtrl>("note_label_2")->setTextArg("[NOTE2]", LLStringExplicit(""));
+ }
+
+ LLFloater::draw();
}