spectral icon indicating copy to clipboard operation
spectral copied to clipboard

Memory Leak

Open samirachamplin opened this issue 3 years ago • 0 comments

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.

Screen Shot 2022-07-22 at 1 46 41 PM Screen Shot 2022-07-22 at 2 39 10 PM Screen Shot 2022-07-22 at 2 39 21 PM

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

samirachamplin avatar Jul 25 '22 21:07 samirachamplin