Returns a stable, predictable index for the object, useful for diagnostics and tracking object lifecycles.
Product:
Class:
Warning
uCalc API Preview Release Notice:The uCalc engine has successfully transitioned to modern cross-platform environments.The next phase envolves some structural changes, performance optimizations, and API refinements.The API is subject to breaking changes prior to the stable release. Please evaluate the preview version thoroughly before production use.
The MemoryIndex method returns a stable, predictable integer that uniquely identifies an object within its class for the duration of its lifetime. It is primarily a tool for advanced debugging, diagnostics, and tracking object lifecycles.
MemoryIndex is assigned sequentially. The first Item created will have index 1, the second will have index 2, and so on..Release()), its MemoryIndex is returned to a pool and will be reused by the next object of the same type that is created. This is a key behavior to understand when debugging.MemoryIndex vs. HandleIt is crucial to distinguish MemoryIndex from an object's Handle.
| Feature | MemoryIndex | Handle |
|---|---|---|
| Stability | Stable & Predictable. Sequential integers. | Volatile. A memory address that changes between runs. |
| Uniqueness | Unique for its lifetime, but recycled after release. | Guaranteed unique for the object's lifetime. Never recycled. |
| Purpose | High-level diagnostics, logging, lifecycle tracking. | Low-level object identification for the C++ core. |
| Use Case | "Is this the same object slot I saw before?" | "What is the exact memory reference for this object?" |
GetHashCode(): While GetHashCode() provides an integer, it is not guaranteed to be unique, nor is it stable between application runs. MemoryIndex is deterministic and predictable within a single run.Handle. MemoryIndex provides a higher-level, more stable identifier that is independent of memory layout.The MemoryIndex gives developers a reliable tool for introspection that bridges the gap between low-level memory addresses and high-level object references.
This page last modified on: