mantis 8551: Simplify Yengine heap usage control

This commit is contained in:
UbitUmarov
2019-11-18 17:33:02 +00:00
parent 496a2228f5
commit bf0697d5f4
5 changed files with 66 additions and 108 deletions

View File

@@ -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;
}
/**