Module

# Runtime

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Returns information about the current state of the <span class="title-ref">Runtime</span> environment. This information can be useful for debugging purposes.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                               | Type                                              | Read-Only | Shared |
|------------------------------------|---------------------------------------------------|-----------|--------|
| `MemoryUsed<runtime.memoryused>`   | `UInt64</api/data_types/additional_types/uint64>` | ✓         |        |
| `ObjectCount<runtime.objectcount>` | `Integer</api/data_types/integer>`                | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                     | Parameters                                  | Returns                                                      | Shared |
|------------------------------------------|---------------------------------------------|--------------------------------------------------------------|--------|
| `IterateObjects<runtime.iterateobjects>` |                                             | `ObjectIterator</api/language/introspection/objectiterator>` |        |
| `ObjectClass<runtime.objectclass>`       | index As `Integer</api/data_types/integer>` | `String</api/data_types/string>`                             |        |
| `ObjectID<runtime.objectid>`             | index As `Integer</api/data_types/integer>` | `Integer</api/data_types/integer>`                           |        |
| `ObjectRefs<runtime.objectrefs>`         | index As `Integer</api/data_types/integer>` | `Integer</api/data_types/integer>`                           |        |

## Enumerations

<div id="runtime.iostreamhandletypes">

<div class="rst-class">

forsearch

</div>

</div>

Runtime.IOStreamHandleTypes

### IOStreamHandleTypes

> Specifies the type of Handle.
>
> | Enum        |
> |-------------|
> | Win32       |
> | FilePointer |
> | FileNumber  |

## Property descriptions

<div id="runtime.memoryused">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Runtime.MemoryUsed

**MemoryUsed** As `UInt64</api/data_types/additional_types/uint64>`

> Returns the total amount of memory used (in bytes) by the allocated objects.
>
> More specifically, this returns the number of malloc'd bytes. Since the OS does not immediately give back memory after it is released there is no guarantee that this number will match OS values that you see in Activity Monitor, Task Manager or top.
>
> This property is read-only.

<div id="runtime.objectcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Runtime.ObjectCount

**ObjectCount** As `Integer</api/data_types/integer>`

> Returns the current number of objects in existence.
>
> This property is read-only.

## Method descriptions

<div id="runtime.iterateobjects">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Runtime.IterateObjects

**IterateObjects** As `ObjectIterator</api/language/introspection/objectiterator>`

> Iterates over the objects in the <span class="title-ref">Runtime</span> environment. Use it to get the `TypeInfo</api/language/introspection/typeinfo>` for each object. See the `ObjectIterator</api/language/introspection/objectiterator>` class for an example.
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> This method is not safe to use in a thread.
>
> </div>

<div id="runtime.objectclass">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Runtime.ObjectClass

**ObjectClass**(index as `Integer</api/data_types/integer>`) As `String</api/data_types/string>`

> ObjectClass returns the class of the passed object.
>
> The *index* must be greater than or equal to zero and less than the `ObjectCount<runtime.objectcount>`.

<div id="runtime.objectid">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Runtime.ObjectID

**ObjectID**(index as `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

> ObjectID returns a unique identifier for the passed object.
>
> The *index* must be greater than or equal to zero and less than the `ObjectCount<runtime.objectcount>`.

<div id="runtime.objectrefs">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Runtime.ObjectRefs

**ObjectRefs**(index as `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

> ObjectRefs returns the number of references to the passed object.
>
> The *index* must be greater than or equal to zero and less than the `ObjectCount<runtime.objectcount>`.

## Sample code

The following code displays the properties related to individual objects in a multicolumn `ListBox</api/user_interface/desktop/desktoplistbox>` and the total amount of memory used in a `TextField</api/user_interface/desktop/desktoptextfield>`:

``` xojo
Var lastObjectIndex As Integer = Runtime.ObjectCount - 1
For i As Integer = 0 To lastObjectIndex
  Listbox1.AddRow(Runtime.ObjectID(i).ToString)
  Listbox1.CellTextAt(ListBox1.LastAddedRowIndex, 1) = Runtime.ObjectClass(i)
  Listbox1.CellTextAt(ListBox1.LastAddedRowIndex, 2) = Runtime.ObjectRefs(i).ToString
Next
TextField1.Text = Runtime.MemoryUsed.ToString
```

## Compatibility

|                       |                               |
|-----------------------|-------------------------------|
| **Project Types**     | Console, Desktop, Mobile, Web |
| **Operating Systems** | iOS, Linux, macOS, Windows    |

<div class="seealso">

`ObjectIterator</api/language/introspection/objectiterator>` class; `System</api/os/system>` module.

</div>
