glamor: memory leak for styles that change across many values

since we generate/add css rules to the dom as soon they’re computed, style objects that change over many different values will leave behind unused rules in the dom. while there exists a function remove to remove rules based on the generated hash/refs, I can’t think of a simple way to expose it. Hopefully this is an edge case and doesn’t affect many people. If so, the recommendation is to use use regular style prop for styles that change over many different values.

of note: this problem is not unique to this lib.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I could probably fix this in a <Style> component’s componentWillReceiveProps. In this case, I would just treat the return value of a call to style as state and call remove if I detect different props. I’ll give it a shot.

@rtfeldman I think he is talking about the rule limit:

stylesheets can have upto 65536 rules,

I don’t think it’s going to cause problems, especially if you do most of your style/variant calls in the beginning. Haven’t seen any real problems in practice either. That said, I’m going to spend the next week actually measuring and validating these claims, you’ll be one of the first to know when it comes 😃