GoogleChromeLabs / react-adaptive-hooks

Deliver experiences best suited to a user's device and network constraints
Apache License 2.0
5.1k stars 113 forks source link

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

Open bharathnayak03 opened 4 years ago

bharathnayak03 commented 4 years ago

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 commented 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:

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

anton-karlovskiy commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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.