Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot free up memory used by entryCache in Modules #259

Closed
sengleung opened this issue Nov 7, 2023 · 0 comments · Fixed by #260
Closed

Cannot free up memory used by entryCache in Modules #259

sengleung opened this issue Nov 7, 2023 · 0 comments · Fixed by #260

Comments

@sengleung
Copy link
Contributor

entryCache is instantiated by Modules

// entryCache is used to prevent unnecessary recursion into previously
// converted nodes.
entryCache map[Node]*Entry

and is used only by the ToEntry function.

goyang/pkg/yang/entry.go

Lines 562 to 567 in a34098e

if e := ms.entryCache[n]; e != nil {
return e
}
defer func() {
ms.entryCache[n] = e
}()

entryCache in Modules can take up a bit of amount of memory after processing all YANG modules. For our use case, after processing all YANG modules, calls to ToEntry, which accesses the entryCache, happen very infrequently, if at all. Therefore, it is ideal to clear the cache to free up memory.

I don't think this should not compromise on correctness. Even if entryCache is cleared, calling ToEntry will just recurse and cache the relevant nodes again.

Issue #248 also refers to this issue. Creating this issue as this relates only to entryCache.

sengleung added a commit to sengleung/goyang that referenced this issue Nov 7, 2023
This function clears the entryCache in Modules to free up memory
after processing modules. entryCache is used by the ToEntry function
to cache previously converted nodes.

Fixes openconfig#259
wenovus pushed a commit that referenced this issue Nov 7, 2023
This function clears the entryCache in Modules to free up memory
after processing modules. entryCache is used by the ToEntry function
to cache previously converted nodes.

Fixes #259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant