# Memory

### Memory Class

The Memory class reports on script pool memory use.

### Syntax

### Member Details

#### ActivityLevel Property

> Current memory activity level since start of last memory counting.
>
> #### Syntax
>
> public [float](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Single) **ActivityLevel** { get; }
>
> **Value**
>
> > uint
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PeakUsedBytes Property

> The highest level of memory used by the script pool.
>
> #### Syntax
>
> public [uint](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt32) **PeakUsedBytes** { get; }
>
> **Value**
>
> > uint
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PolicyCritical Property

> Current policy Critical level of used memory by the script pool
>
> #### Syntax
>
> public [uint](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt32) **PolicyCritical** { get; }
>
> **Value**
>
> > uint
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PolicyLimit Property

> Current policy Limit level of used memory by the script pool
>
> #### Syntax
>
> public [uint](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt32) **PolicyLimit** { get; }
>
> **Value**
>
> > uint
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### PolicyWarning Property

> Current policy Warning level of used memory by the script pool
>
> #### Syntax
>
> public [uint](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt32) **PolicyWarning** { get; }
>
> **Value**
>
> > uint
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Subscribe Method

> Subscribes to Memory Events.
>
> #### Syntax
>
> \[System.Obsolete("Use subscription callbacks of type Action\<Sansar.Script.MemoryData>", false)]\
> public [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **Subscribe** ([Memory.SubscriptionHandler](https://help.sansar.com/hc/en-us/articles/115003436903) callback, [bool](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean) persistent)
>
> **Parameters**
>
> > *callback*
> >
> > Callback which is executed when the event completes.
> >
> > *persistent*
> >
> > Optional, set to false to unsubscribe after one event.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Subscribe Method

> Subscribes to Memory Events.
>
> #### Syntax
>
> **See Also**
>
> **Parameters**
>
> > *callback*
> >
> > Callback which is executed when the event completes.
> >
> > *persistent*
> >
> > Optional, set to false to unsubscribe after one event.
>
> **Returns**
>
> > An [Sansar.Script.IEventSubscription](/latest/script-api-docs/sansar-script-namespace/ievent-subscription.md) that can be used to cancel the subscription.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### ToString Method

> A string representation of this object.
>
> #### Syntax
>
> public override [string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) **ToString** ()
>
> **Returns**
>
> > A string representation of this object.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### UsedBytes Property

> Total bytes used by this script pool as of last accounting.
>
> #### Syntax
>
> public [uint](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt32) **UsedBytes** { get; }
>
> **Value**
>
> > uint
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

### Memory.SubscriptionHandler Delegate

Notifies scripts about memory events.

### Syntax

\[System.Obsolete("Use subscription callbacks of type Action\<Sansar.Script.MemoryData>", false)]\
public delegate [void](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void) **Memory.SubscriptionHandler** ([uint](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt32) TrackingId, [MemoryUseLevel](https://help.sansar.com/hc/en-us/articles/115001996766) UseLevel)

**Parameters**

> *TrackingId*
>
> The id of the animation component.L:\p\Sansar\SharedBranches\ServerScript\Code\Common\Libraries\LLScript/Apis/ScriptMemory.h(75)The id of the component generating the event.
>
> *UseLevel*
>
> The behavior name of the Animation.L:\p\Sansar\SharedBranches\ServerScript\Code\Common\Libraries\LLScript/Apis/ScriptMemory.h(75)This name will match the subscribed event.

### Remarks

### Requirements

**Namespace:** Sansar.Script\
**Assembly:** Sansar.Script (in Sansar.Script.dll)\
**Assembly Versions:** 1.0.0.0

### MemoryData Class

Notifies scripts about memory events.

### Syntax

### Member Details

#### ToString Method

> A string representation of this object.
>
> #### Syntax
>
> public override [string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) **ToString** ()
>
> **Returns**
>
> > A string representation of this object.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### TrackingId Property

> Internal Id of the memory tracker.D:\work\647144a9cd6c61be\Sansar\Code\Common\Libraries\LLScript/Apis/CsScriptMemory.h(84)Used for routing the event.
>
> #### Syntax
>
> public [uint](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt32) **TrackingId** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### UseLevel Property

> The level subscribed to.D:\work\647144a9cd6c61be\Sansar\Code\Common\Libraries\LLScript/Apis/CsScriptMemory.h(84)
>
> #### Syntax
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Script\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

### MemoryUseLevel Enum

Used by [Sansar.Script.Memory](https://help.sansar.com/hc/en-us/articles/115001972446) to report script memory use.

### Syntax

public enum **MemoryUseLevel**

### Remarks

### Members

| Member Name  | Description                                                                |
| ------------ | -------------------------------------------------------------------------- |
| **Critical** | Critical memory use, nearing limit.                                        |
| **Limit**    | Memory limit hit, if nothing is done scripts in this pool may be disabled. |
| **Low**      | Script memory use under Warning level.                                     |
| **Warning**  | First warning of high memory use.                                          |

### Requirements

**Namespace:** Sansar.Script\
**Assembly:** Sansar.Script (in Sansar.Script.dll)\
**Assembly Versions:** 1.0.0.0


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sansar.com/latest/script-api-docs/sansar-script-namespace/memory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
