uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Provides a programmatic way to query uCalc's internal memory usage, detailing allocations for specific internal object types or the entire engine.
Returns the requested memory metric (e.g., total bytes, number of active elements) based on the Count and Option parameters.
The DiagMem method offers advanced diagnostic capabilities for monitoring uCalc's internal memory footprint. While primarily intended for internal testing and development, it is invaluable for developers seeking to optimize performance, troubleshoot memory-related issues, or understand the resource consumption of complex expressions within their applications.
uCalcIndex: This parameter identifies the specific uCalc engine instance whose memory you wish to diagnose. The index can be obtained by calling the uCalc.MemoryIndex method on any object associated with that engine instance.
Target: Use a member of the uCalc.BuiltInType enumeration to specify which internal component's memory you want to inspect. Use a Diag* member, such as BuiltInType::DiagParsedExpression for parsed expression trees, BuiltInType::DiagDataType for internal data type definitions, or BuiltInType::DiagAll to get a consolidated view.
Count: This parameter, utilizing the DiagMemCount enumeration, determines what metric DiagMem should return. You can choose to count the total Bytes consumed, the number of active Elements, or other metrics.
Option: This parameter, using the DiagMemOption enumeration, refines the memory measurement. Options include Default (typically Active), Active (current memory usage), or Peak (maximum memory usage observed since the uCalc instance's creation).
Traditional memory profiling often involves external tools like Valgrind (for C/C++), Visual Studio Diagnostic Tools, or language-specific profilers. While powerful for application-wide analysis, they may not provide granular insight into the specific internal data structures of a component like uCalc.
DiagMem offers a unique advantage: it is an integrated, programmatic memory profiler specifically tailored for the uCalc engine. Instead of interpreting complex external profiler reports, developers can directly query uCalc's internal state. This allows for: