OsGetSimulatorMemory

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (some format conversions)
m (XEngine to OSSL)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{osslfunc
 
{{osslfunc
 
|threat_level=Moderate
 
|threat_level=Moderate
|function_syntax=osGetSimulatorMemory();
+
|permissions=${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
 +
|delay=0
 +
|function_syntax=integer osGetSimulatorMemory();
 
|ossl_example=Simple Script (displays only the integer such as 234652064)
 
|ossl_example=Simple Script (displays only the integer such as 234652064)
  
Line 13: Line 15:
 
  {
 
  {
 
  TotMemUsed = osGetSimulatorMemory();
 
  TotMemUsed = osGetSimulatorMemory();
  llSetText( (string)TotMemUsed+" Memory by the OpenSim Instance", <0.0,1.0,0.0>, 1.0 );
+
  llSetText( (string)TotMemUsed+" Memory by the OpenSimulator Instance", <0.0,1.0,0.0>, 1.0 );
 
  }
 
  }
 
  touch(integer num)
 
  touch(integer num)
 
  {
 
  {
 
  TotMemUsed = osGetSimulatorMemory();
 
  TotMemUsed = osGetSimulatorMemory();
  llSetText( (string)TotMemUsed+" Memory by the OpenSim Instance", <0.0,1.0,0.0>, 1.0 );
+
  llSetText( (string)TotMemUsed+" Memory by the OpenSimulator Instance", <0.0,1.0,0.0>, 1.0 );
 
  }
 
  }
 
}
 
}
Line 30: Line 32:
 
// shows either MB or GB as applicable
 
// shows either MB or GB as applicable
 
//
 
//
// ==== GET Memory INteger and Format for Display ====
+
// ==== GET Memory Integer and Format for Display ====
 
GenStats()
 
GenStats()
 
{
 
{
Line 36: Line 38:
 
  string TotalMem;
 
  string TotalMem;
 
  string TotMemUsed;
 
  string TotMemUsed;
  string TxtTail =" used by OpenSim Instance";
+
  string TxtTail =" used by OpenSimulator Instance";
 
   
 
   
 
  TotMemUsed = (string)osGetSimulatorMemory();
 
  TotMemUsed = (string)osGetSimulatorMemory();
Line 82: Line 84:
 
}
 
}
 
</source>
 
</source>
 +
<br />
 +
'''Limitations'''<br />
 +
This function returns a signed 32-bit integer. This limits the value returned by this function to a maximum of 2GB even if the actual amount of memory in use exceeds 2GB.
 
|description=Implemented December 12,2009 by Adam Frisby in GIT# 87e89efbf9727b294658f149c6494fd49608bc12 - Rev 11700
 
|description=Implemented December 12,2009 by Adam Frisby in GIT# 87e89efbf9727b294658f149c6494fd49608bc12 - Rev 11700
 
|
 
|
 
}}
 
}}

Latest revision as of 07:41, 7 November 2019

integer osGetSimulatorMemory();
Implemented December 12,2009 by Adam Frisby in GIT# 87e89efbf9727b294658f149c6494fd49608bc12 - Rev 11700
Threat Level Moderate
Permissions ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Extra Delay 0 seconds
Example(s)
Simple Script (displays only the integer such as 234652064)
// Simple Unformatted Output
// 
integer TotMemUsed;
default
{
 state_entry()
 {
 TotMemUsed = osGetSimulatorMemory();
 llSetText( (string)TotMemUsed+" Memory by the OpenSimulator Instance", <0.0,1.0,0.0>, 1.0 );
 }
 touch(integer num)
 {
 TotMemUsed = osGetSimulatorMemory();
 llSetText( (string)TotMemUsed+" Memory by the OpenSimulator Instance", <0.0,1.0,0.0>, 1.0 );
 }
}


Extended with some formatting: (displays as 234.652 Mb)

// Simple formatted Output
// shows either MB or GB as applicable
//
// ==== GET Memory Integer and Format for Display ====
GenStats()
{
 // Get Memory and format it
 string TotalMem;
 string TotMemUsed;
 string TxtTail =" used by OpenSimulator Instance";
 
 TotMemUsed = (string)osGetSimulatorMemory();
 integer Len = llStringLength(TotMemUsed);
 
 if(Len == 8) // ##.### MB
 {
 string Mem1 = llGetSubString(TotMemUsed,0,1);
 string Mem2 = llGetSubString(TotMemUsed,2,4);
 TotalMem = Mem1 + "." + Mem2 + "\nMb"+TxtTail;
 }
 else if(Len == 9) //###.### MB
 {
 string Mem1 = llGetSubString(TotMemUsed,0,2);
 string Mem2 = llGetSubString(TotMemUsed,3,5);
 TotalMem = Mem1 + "." + Mem2 + "\nMb"+TxtTail;
 }
 else if(Len == 10) //#.### GB
 {
 string Mem1 = llGetSubString(TotMemUsed,0,0);
 string Mem2 = llGetSubString(TotMemUsed,1,3);
 TotalMem = Mem1 + "." + Mem2 + "\nGb"+TxtTail;
 }
 else if(Len == 11) //##.### GB
 {
 string Mem1 = llGetSubString(TotMemUsed,0,1);
 string Mem2 = llGetSubString(TotMemUsed,2,4);
 TotalMem = Mem1 + "." + Mem2 + "\nGb"+TxtTail;
 }
 
 llSetText(TotalMem, <0.0,1.0,0.0>, 1.0 );
}
 
default
{
 state_entry() // display @ start
 {
 GenStats();
 }
 
 touch(integer num) // refresh on touch
 {
 GenStats();
 }
}


Limitations
This function returns a signed 32-bit integer. This limits the value returned by this function to a maximum of 2GB even if the actual amount of memory in use exceeds 2GB.

Personal tools
General
About This Wiki