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

fix: Memory leak caused by global variables. #686

Merged
merged 1 commit into from Apr 29, 2021
Merged

Conversation

ygj6
Copy link
Member

@ygj6 ygj6 commented Apr 23, 2021

Fix: #685

@ygj6
Copy link
Member Author

ygj6 commented Apr 23, 2021

proxy(ctx, key, {
get() {
return (...args: any[]) => {
const fn: Function = vm[srcKey]
fn.apply(vm, args)
}
},

const sharedPropertyDefinition = {
enumerable: true,
configurable: true,
get: noopFn,
set: noopFn,
}
export function proxy(
target: any,
key: string,
{ get, set }: { get?: Function; set?: Function }
) {
sharedPropertyDefinition.get = get || noopFn
sharedPropertyDefinition.set = set || noopFn
Object.defineProperty(target, key, sharedPropertyDefinition)
}

When mounting the setter and getter, a reference to the current vue instance by the global variable sharedPropertyDefinition appears.

@antfu antfu merged commit badff82 into vuejs:master Apr 29, 2021
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 this pull request may close these issues.

vue + compositionApi will cause memory leaks!
2 participants