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

sharedIndex use Too Much Memory. Add option to let runtime use a standalone index. #1418

Closed
kentalee opened this issue Dec 8, 2021 · 1 comment
Labels
FeatureRequest New feature or request Triage Requires triage/attention

Comments

@kentalee
Copy link

kentalee commented Dec 8, 2021

Is your feature request related to a problem? Please describe.

I have large amount of cue file which should be paesed and decoded to struct when program starting.
I found allocated memory does not decrease after my instance set to nil, and many objects still used by core/runtime.sharedIndex
In my case, I do not need cue to hold config information after program loaded.
I hope memory freed after instance destroyed.

Describe the solution you'd like

Add option to core/runtime.New or core/runtime.Init, to let runtime use a clone of sharedIndex. e.g.

// internal/core/runtime/runtime.go

func (r *Runtime) Init() {
	if r.index != nil {
		return
	}
	// r.index = sharedIndex
	r.index = sharedIndex.Clone()
	r.loaded = map[*build.Instance]interface{}{}
}
// internal/core/runtime/imports.go

func (x *index) Clone() *index {
    var n = newIndex()
    // clone data from x ......
    return n
}

Describe alternatives you've considered

Maybe we have some way for user to clear sharedIndex ?

Additional context

@kentalee kentalee added FeatureRequest New feature or request Triage Requires triage/attention labels Dec 8, 2021
@kentalee
Copy link
Author

duplicate to #1424

cueckoo pushed a commit that referenced this issue Feb 19, 2022
This was always supposed to be this way, but dropped off
the radar as a thing to do.

Fixes #1424
Fixes #1418
Issue #1414

Signed-off-by: Marcel van Lohuizen <mpvl@golang.org>

Change-Id: I25b486d2ea1c6009b00732a113af29bd485f9df5
cueckoo pushed a commit that referenced this issue Feb 22, 2022
This was always supposed to be this way, but dropped off
the radar as a thing to do.

Fixes #1424
Fixes #1418
Issue #1414

Signed-off-by: Marcel van Lohuizen <mpvl@golang.org>

Change-Id: I25b486d2ea1c6009b00732a113af29bd485f9df5
Signed-off-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/533473
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request Triage Requires triage/attention
Projects
None yet
Development

No branches or pull requests

1 participant