-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathcache.go
More file actions
30 lines (26 loc) · 1.09 KB
/
cache.go
File metadata and controls
30 lines (26 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2022-2026 Princess B33f Heavy Industries / Dave Shanley
// SPDX-License-Identifier: MIT
package libopenapi
import (
highbase "github.com/pb33f/libopenapi/datamodel/high/base"
"github.com/pb33f/libopenapi/datamodel/low"
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/utils"
)
// ClearAllCaches resets every global in-process cache in libopenapi.
// Call this between document lifecycles in long-running processes
// (servers, CLI tools that process many specs) to release memory that
// would otherwise accumulate and never be garbage-collected.
func ClearAllCaches() {
low.ClearHashCache() // hashCache + indexCollectionCache
lowbase.ClearSchemaQuickHashMap() // SchemaQuickHashMap
index.ClearHashCache() // nodeHashCache
index.ClearContentDetectionCache()
highbase.ClearInlineRenderingTracker()
utils.ClearJSONPathCache()
// Drain sync.Pool instances that hold *yaml.Node pointers.
// Pooled slices/maps keep the entire YAML parse tree alive.
index.ClearNodePools()
low.ClearNodePools()
}