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

Include memory stats when memory warning occurs. #4891

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

bengtan
Copy link
Contributor

@bengtan bengtan commented Mar 10, 2020

Try to get stats from real world devices.

Just trying to help with #4055.

Since @aksonov is working on #4055, this should be reviewed by him (at least).

@bengtan bengtan requested a review from aksonov March 10, 2020 07:21
Copy link
Contributor

@aksonov aksonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aksonov aksonov merged commit 3273049 into master Mar 10, 2020
@bengtan bengtan deleted the memory-warning-post-stats branch March 11, 2020 04:03

const App = () => {
const [store, setStore] = useState<any>(null)

useEffect(() => {
// This seems to be undocumented event.
AppState.addEventListener('memoryWarning', () => {
const extras = {currentState: AppState.currentState}
AppState.addEventListener('memoryWarning', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're doing this on a top-level component we probably don't need to worry about removing this listener later, but just something to think about if we start to see performance drop-off

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I guess this listener has been in for a while already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I implemented the listener (it was a long time ago), it was pre-useEffect and AppState.addEventListener was supposed to happen only once per app invocation. Hence, I didn't see a need to remove it.

Are you implying that, after it was moved into useEffect, it can happen more than once?

If so, then ... how about moving it back outside of useEffect?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naw, it's fine as is

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

Successfully merging this pull request may close these issues.

3 participants