-
Notifications
You must be signed in to change notification settings - Fork 357
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
[prism-cli] Memory leak while validating (Deluxe Edition) #1908
Comments
@radzserg @lukasz-kuzynski-11sigma 👋 Any feedback? Have you been able to repro this on your side? Sadly this compelled us to rollback to Prism 4.1.2. :-/ |
Hey team! Please add your planning poker estimate with ZenHub @Amjcraft @lukasz-kuzynski-11sigma @radzserg @rainum @EdVinyard |
Hi @nulltoken Thank You for your patience and a finding of a bug! :) I can confirm that once prism gets reloaded upon spec change and performing some requests there is some memory leak. The source of it is https://www.npmjs.com/package/ajv package that creates new function for each validated schema. The way the validation function is being created (via Possible solutions we took into account:
Moreover what I found is that I'm really curious why you went back to version 4.1.2? AJV was there and causing memory leaks on spec reload too. Why is running 4.4.x is problematic? How big is memory growth? Also I'm very curious about the general increase of memory usage. I've tested it locally by changing the spec every second and making few requests in that time and the increase wasn't so big. Is it feasible for You to just restart the prism once a day? The cache introduced by my previous fix is not a source of a leak since it relies on Closing for now. If we find this issue serious this will be obviously reopened. |
Describe the bug
This is a follow up to #1881.
We've discovered another leaky scenario. See below for the repro case.
Note: This may look like a contrived scenario but this is the trimmed down version of a production real issue.
Basically we host Prism and use it to validate the traffic (requests/responses). Every time the specs are updated, which may happen many times a week, we trigger a "refresh" which makes Prism load and parse the new version of the specs and build a new array of
IHttpOperation
from it. Each time this happens, we leak a little memory.To Reproduce
A complete standalone repro case is available at https://github.com/nulltoken/prism_repro
It triggers a loop of 5000 request and response validations, capturing the amount of used Heap every 10 steps, and triggering a garbage collection between every step.
Running
yarn repro
shows the following output where one can clearly see the heap growing.Expected behavior
As far as my understanding goes, there are at least two levels of JsonSchema/ValidatingFunction caching: one at the Prism level and a second one at Ajv level.
In our scenario, I believe that what would make the most sense would be a way to "clear" the caches every time we "refresh" the list of operations.
Thoughts?
/cc @chohmann @radzserg @lukasz-kuzynski-11sigma
The text was updated successfully, but these errors were encountered: