uCalc API Version: 2.1.3-preview.2 Released: 6/16/2026

Warning

uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.

ResetAll

Method

Product: 

Fast Math Parser

Class: 

uCalcBase

Resets the entire uCalc library to its initial startup state, releasing all instances and clearing all definitions.

Syntax

ResetAll()

Parameters

[None]

Return

void

This method does not return a value.

Remarks

The static ResetAll() method is a global, application-wide function that restores the uCalc library to its pristine, out-of-the-box state. It is a powerful tool for ensuring a clean environment, particularly in testing scenarios or applications with complex, dynamic configurations.

⚙️ What ResetAll Does

Calling this function performs the following actions:

  1. Releases All Instances: Every uCalc instance created during the application's lifetime is released, freeing all associated memory.
  2. Clears the Default Stack: It completely clears the default instance stack, which is managed by methods like IsDefault.
  3. Resets the Root Default: It restores the original, built-in DefaultInstance instance to its initial state, removing any user-defined functions, variables, or settings.

🎯 When to Use ResetAll

ResetAll is the most comprehensive cleanup tool and should be used when you need to guarantee a completely fresh start. Common use cases include:

  • Unit Testing: It is best practice to call ResetAll() in the TearDown or afterEach method of a test suite to ensure that each test runs in a perfectly isolated environment, free from any state created by previous tests.
  • Application-Level Reset: In applications that allow users to script or configure the engine, ResetAll can power a "Reset to Factory Defaults" feature.
  • Recovering from Errors: In an interactive or long-running session, it provides a reliable way to recover from a state where definitions may have become corrupted or are no longer needed.

🆚 ResetAll vs. Other Reset Methods

It is crucial to choose the correct cleanup method for your needs. ResetAll is the most powerful and destructive option.

MethodScopeEffect
ResetAll()Global (Library-wide)Destroys all uCalc instances and resets the entire library.
DefaultClear()Default Instance StackRemoves all custom default instances and resets only the original, root default instance. Other instances are unaffected.
instance.Release()Single InstanceReleases one specific uCalc instance and its associated resources.

⚠️ Warning: Because ResetAll() affects the entire application, use it with care. Calling it will invalidate all existing uCalc object handles, including any that may still be in scope.

Examples