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

SSR Memory leak #20

Open
Shenmin-Z opened this issue Jun 13, 2019 · 4 comments · May be fixed by #36
Open

SSR Memory leak #20

Shenmin-Z opened this issue Jun 13, 2019 · 4 comments · May be fixed by #36

Comments

@Shenmin-Z
Copy link

I recently added this package in our project and I was told it's causing memory leak in our prod env.

After reading the code, it seems like it's the sanitized cache that's causing the problem.

sanitized[s] = true;

Every generated html string(s) would be stored in this cache, and it seems to have caused our server run out of memory and keeps restarting.

@atlas1119
Copy link

Has it been solved?

@developit
Copy link
Owner

developit commented Dec 4, 2019

This is still an issue. Switching to a WeakMap would likely help. I opened a PR with a basic implementation.

@zhuscat
Copy link

zhuscat commented Jul 21, 2022

It seems like the problem has not been solved yet. Is there any plan? 😭

developit added a commit that referenced this issue Jul 21, 2022
@developit developit linked a pull request Jul 21, 2022 that will close this issue
@luwes
Copy link

luwes commented Oct 8, 2022

I'm integrating part of this library in an experiment and ran into this issue.

another potential solution is to add an indicator to the "child" that it was generated by h() so no need to store any global collection. the child could add a property to the html string it returns (not sure if this has browser memory implications and it's kind of hacky).

or instead of returning the string s maybe return lightest possible object structure with a toString() method
e.g. { h: true, toString() { return s; } }

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

Successfully merging a pull request may close this issue.

5 participants