spectral
spectral copied to clipboard
Memory Leak
Describe the bug
There appears to be a memory leak with spectral. The resident memory on the machine continues to rise with each validation, and eventually runs out of space and crashes.
To Reproduce
Repeatedly lint a document with spectral.run() in a loop.
Here is the example code snippet that was used:
export async function validate(spec: string): Promise<ISpectralDiagnostic[]> {
const spectral = new Spectral();
const ruleset = new Ruleset({extends: [oas]})
spectral.setRuleset(ruleset);
while (true) {
const result = await spectral.run(spec);
console.log(result.length);
}
return spectral.run(spec);
}
Expected behavior We would expect resident memory to be cleared so the app doesn't crash.
Screenshots
See RES where the residential memory continues to rise. These were captured with htop.
Environment (remove any that are not applicable):
- "@stoplight/spectral-core": "^1.12.2",
- "@stoplight/spectral-formats": "^1.2.0",
- "@stoplight/spectral-functions": "^1.6.1",
- "@stoplight/spectral-rulesets": "^1.9.0",
- OS: macOS Big Sur