From 3d6553afeee3d4605851b6f336c17d5a6b07c6ad Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 15 Oct 2017 14:46:21 +0100
Subject: add osGetSimulatorMemoryKB(). This allows work around the fact
osGetSimulatorMemory() reports at most 2GB. This one limit is now 2TB, should
ne enought for a while
---
.../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 16 ++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 +
.../Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 7 ++++++-
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 79367fb..ba07f9c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3591,6 +3591,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return (int)pws;
}
+ public int osGetSimulatorMemoryKB()
+ {
+ CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory");
+
+ long pws = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
+
+ if((pws & 0x3FFL) != 0)
+ pws += 0x400L;
+ pws >>= 10;
+
+ if (pws > Int32.MaxValue)
+ return Int32.MaxValue;
+
+ return (int)pws;
+ }
+
public void osSetSpeed(string UUID, LSL_Float SpeedModifier)
{
CheckThreatLevel(ThreatLevel.Moderate, "osSetSpeed");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 429860b..ffb7ded 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -379,6 +379,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
vector osGetRegionSize();
int osGetSimulatorMemory();
+ int osGetSimulatorMemoryKB();
void osKickAvatar(string FirstName,string SurName,string alert);
void osSetSpeed(string UUID, LSL_Float SpeedModifier);
LSL_Float osGetHealth(string avatar);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 23ea215..30ff764 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -958,7 +958,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
///
/// Returns the amount of memory in use by the Simulator Daemon.
- /// Amount in bytes - if >= 4GB, returns 4GB. (LSL is not 64-bit aware)
+ /// Amount in bytes - if >= 2GB, returns 2GB. (LSL is not 64-bit aware)
///
///
public LSL_Integer osGetSimulatorMemory()
@@ -966,6 +966,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osGetSimulatorMemory();
}
+ public LSL_Integer osGetSimulatorMemoryKB()
+ {
+ return m_OSSL_Functions.osGetSimulatorMemoryKB();
+ }
+
public void osKickAvatar(string FirstName,string SurName,string alert)
{
m_OSSL_Functions.osKickAvatar(FirstName, SurName, alert);
--
cgit v1.1