Attach memory info to watchdog terminations
Description
The Sentry SDK could sample the memory information once every x seconds and store it with the app state on a bg thread and report that information when a watchdog termination occurs. Then, users would know if the watchdog termination was due to an OOM. This only works for OOMs that slowly add up and not for high spikes in memory pressure.
Related to https://github.com/getsentry/sentry-cocoa/issues/2514, https://github.com/getsentry/sentry-cocoa/issues/3890 and https://github.com/getsentry/sentry-cocoa/issues/3518.
It probably makes sense to tackle this as part of a larger initiative to improve OOM/Watchdog terminations - see linked issues above.
Yes, for now, there is no "app_memory" info when app crashes, but for other events, there is "app_memory" info. This is odd. I just take a look at previous codes, "app_memory" info was first added for crash (#4fb00e9), but later added for other events but removed for crash in later versions. So why? Can this info be added back?
@ljql2001 watchdog termination events currently do not have any app context in their payload. This is a bug and I am working on this in #5242, so maybe this will fix your issue aswell.
@philprime I can see #5242 has already been merged to sentry-cocoa sdk in release 8.52.0. But our app has upgraded to 8.55.1, I make a crush manually, but I still cannot see "app_memory" field in the sentry crush event. Can you help check? Thanks.