SSR Memory leak · Issue #20 · developit/vhtml · GitHub
Skip to content

SSR Memory leak #20

Open
Open

Description

@Shenmin-Z

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.

Activity

  1. atlas1119 commented on Jul 1, 2019

    @atlas1119

    Has it been solved?

  2. developit commented on Dec 4, 2019

    @developit
    Owner

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

  3. zhuscat commented on Jul 21, 2022

    @zhuscat

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

  4. added a commit that references this issue on Jul 21, 2022
    8679db8
  5. luwes commented on Oct 8, 2022

    @luwes

    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; } }

  6. added a commit that references this issue on Oct 22, 2023
    67ff042
  7. geminigeek commented on Jul 23, 2025

    @geminigeek

    memory leak still happening , anyone found a fix ?

  8. TimDaub commented on Oct 21, 2025

    @TimDaub

    Would be good if this was getting fixed, this is taking down a prod server of mine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions