JsonSchemaResultsCollector.Dispose Method
Definition
Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Source: JsonSchemaResultsCollector.cs
Dispose()
Releases all resources and returns the collector to the pool if rented, ensuring proper cleanup of sensitive data.
public void Dispose()
Implements
Remarks
Resource Cleanup Process: - Pooled Instances: Resets state and returns to thread-local cache for reuse - Non-pooled Instances: Clears sensitive data and returns buffers to ArrayPool - Security: All internal buffers containing validation data are explicitly cleared - Stack Cleanup: Internal stacks are disposed and their resources released Security Considerations: The disposal process explicitly clears all internal buffers that may contain sensitive validation data, including validation messages, document paths, and schema paths. This ensures that sensitive information does not persist in memory after validation completion. Performance Impact: Disposal is designed to be efficient, with O(1) pool return for rented instances and O(n) buffer clearing for non-pooled instances where n is the total buffer usage. The explicit clearing overhead is necessary for security but minimal in typical usage scenarios. Important: Always dispose collector instances to ensure proper resource management. Failure to dispose rented instances can lead to pool exhaustion, while failure to dispose non-pooled instances can lead to memory leaks and security concerns.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests.
Open an issue