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

Enable JSVM consumes a lot of memory #2702

Closed
lcx102737 opened this issue Nov 27, 2019 · 0 comments · Fixed by #2751
Closed

Enable JSVM consumes a lot of memory #2702

lcx102737 opened this issue Nov 27, 2019 · 0 comments · Fixed by #2751
Labels

Comments

@lcx102737
Copy link

Branch/Environment/Version

  • Branch/Version: v2.8.2
  • Environment: centos7

Describe the bug
Enable JSVM consumes a lot of memory

Reproduction steps

  1. enable JSVM
  2. register api
  3. top tyk

Actual behavior
The registration API calls jsvm.init, whether or not the API use js

Expected behavior
When register the compose API calls jsvm.init

code
The API type is not determined before calling spec.jsvm.init

func (a APIDefinitionLoader) MakeSpec(def *apidef.APIDefinition, logger *logrus.Entry) *APISpec {
	spec := &APISpec{}

	if logger == nil {
		logger = logrus.NewEntry(log)
	}

	......

	spec.GlobalConfig = config.Global()

	// Create and init the virtual Machine
	if config.Global().EnableJSVM {
		spec.JSVM.Init(spec, logger)
	}
       ......
}

Memory usage is as follows
image

@lcx102737 lcx102737 added the bug label Nov 27, 2019
buger added a commit that referenced this issue Dec 19, 2019
JSVM now initialized ONLY if API actually uses middleware or virtual endpoint. 
Additionally HTTP client which is used to communicate with the dashboard gets re-used for all connections. 

Fix #2752
Fix #2702
tykbot bot pushed a commit that referenced this issue Dec 19, 2019
JSVM now initialized ONLY if API actually uses middleware or virtual endpoint. 
Additionally HTTP client which is used to communicate with the dashboard gets re-used for all connections. 

Fix #2752
Fix #2702

(cherry picked from commit d129c5e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant