Thank you for your quick reply! I’m sure that LaunchAgent is a great workaround for this issue, but it’s a workaround. I wonder if there is any reliable way to fix that issue. My app could be relaunched with no issues, but what if the app is doing some work, or has some unsaved progress, or for any other reason we don’t want the app to be randomly killed and relaunched every couple of minutes?
Usually, we don’t want to fix app crashes by installing an agent relaunching the app. The same way we don’t want to fix app getting killed by the system by installing that agent. It would be a good solution if we want to make sure that the app is always running no matter what happens, but it’s not a good solution if we just want to make sure that the app operates normally as the user expects it to work.
Also, this workaround works only if the user wants to launch the app on every system startup. If the user doesn’t select that option, the workaround is not applicable and the app will be terminated randomly.
Also, setting KeepAlive = true means that the app will be relaunched even if the user decides to quit the app manually, which isn’t a desired behavior. Probably I could intercept a manual termination and update LaunchAgent, but it seems like building a serious logic just to workaround an issue that shouldn’t occur in the first place.
I’m quite sure that my app isn’t heavily using cache, so I’d love to know how to diagnose this problem and how to determine why on my client’s device, only my app is affected by this aggressive clean up macOS behavior.
I think it shouldn’t be considered normal that the app might be killed every couple of minutes just because the user has let’s say 8gb free disk space instead of 30gb.