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

Values like jsHeapSize change over time, whereas useMemoryStatus hook will give a constant value #19

Open
bharathnayak03 opened this issue Nov 14, 2019 · 4 comments

Comments

@bharathnayak03
Copy link

memory info totalJSHeapSize and usedJSHeapSize change over time, whereas useMemoryStatus hook return value which was captured during the module load time.
useInitialMemoryStatus would have been a better name since this hook returns initial memory status.

@addyosmani
Copy link
Collaborator

Thanks for the feedback, @bharathnayak03. We recently switched over to a model where many of the original 'hooks' were changed to offer constant values, with the exception of the Network status hook. I see two options here:

  • We could change the name for the hook or at minimum update the docs to capture that it only returns the initial memory status
  • We can revert memory status back to using useState and provide a way to be updated when heap sizes change

Interested in @wmertens opinions here too... :)

@anton-karlovskiy
Copy link
Contributor

@addyosmani

As we were using the approach from this article, I think we could revert memory status back to React.js hook and add some listener like network hook.

According to my experiment, with a lot of tabs open for a long time on Chrome browser (when memory usage is quite high enough to notice), the previous memory hook based on this article used to work well.

I think it could be better off evaluating memory status than just based on navigator.deviceMemory.

@anton-karlovskiy
Copy link
Contributor

@addyosmani

I'm just wondering if we could explore some approach with which we can evaluate the CPU usage not just the constant value.

@addyosmani
Copy link
Collaborator

As we were using the approach from this article, I think we could revert memory status back to React.js hook and add some listener like network hook.

I would be supportive of this. I think it's worth keeping this issue open a little longer just to give more users a chance to provide more feedback before we make a decision on how to proceed.

Another option would be focusing the memory utility entirely on the constant navigator.deviceMemory value (dropping performance.memory data), however given the original post mentions totalJSHeapSize, I'm inclined to say users probably want this information exposed too.

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

3 participants