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

Memory leak in /base/style.json route #253

Open
allthesignals opened this issue Oct 28, 2021 · 0 comments
Open

Memory leak in /base/style.json route #253

allthesignals opened this issue Oct 28, 2021 · 0 comments

Comments

@allthesignals
Copy link
Collaborator

  1. Run the app locally after fresh reboot, visit /v1/base/style.json. You'll notice it's the exact file in /data/base/style.json.
  2. Visit /v1/layer-groups. Then go back and reload /v1/base/style.json. Notice it's identical to /v1/layer-groups.

This is because of a memory leak located here:
image

This utility imports a "json" file then mutates it. Because the file extension is json, it suggests that it's static and immutable, but it's not — I think it's simply loaded into memory when the app boots and preserves whatever mutations were made the last time the route was loaded. That means /v1/base/style.json will return whatever tiles were generated for which app was last visited. In theory, you could be getting ZoLa style.json when you wanted FactFinder style.json. Spooky!

A quick fix would be create a local copy of style.json in consuming apps. Another approach might be to make a deep copy of style.json in this app. A third might be to look at how it loads static JSON elsewhere in the app using utils/local-resources-utilities/-load-json.js.

@allthesignals allthesignals changed the title Memory Leak Memory leak in /base/style.json route Oct 28, 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

No branches or pull requests

1 participant