From bf0697d5f45cb844868cf1b410737201b16031e1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 18 Nov 2019 17:33:02 +0000 Subject: mantis 8551: Simplify Yengine heap usage control --- OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs') diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs index dec775f..32aea25 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs @@ -453,11 +453,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine \**************************************************/ protected int heapLimit; - protected int heapUsed; + public int m_heapUsed; public virtual int UpdateHeapUse(int olduse, int newuse) { - int newtotal = Interlocked.Add(ref heapUsed, newuse - olduse); + if (m_heapUsed < 0) + m_heapUsed = 0; + int newtotal = Interlocked.Add(ref m_heapUsed, newuse - olduse); if(newtotal > heapLimit) throw new OutOfHeapException(newtotal + olduse - newuse, newtotal, heapLimit); return newuse; @@ -465,17 +467,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine public virtual void AddHeapUse(int delta) { - Interlocked.Add(ref heapUsed, delta); + Interlocked.Add(ref m_heapUsed, delta); } public int xmrHeapLeft() { - return heapLimit - heapUsed; + if (m_heapUsed < 0) + m_heapUsed = 0; + return heapLimit - m_heapUsed; } public int xmrHeapUsed() { - return heapUsed; + if(m_heapUsed < 0) + m_heapUsed = 0; + return m_heapUsed; } /** -- cgit v1.1