Open bharathnayak03 opened 4 years ago
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:
useState
and provide a way to be updated when heap sizes changeInterested in @wmertens opinions here too... :)
@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
.
@addyosmani
I'm just wondering if we could explore some approach with which we can evaluate the CPU usage not just the constant value.
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.
memory info
totalJSHeapSize
andusedJSHeapSize
change over time, whereasuseMemoryStatus
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.