Thanks for sharing!
We can understand a little bit more about what's happening from the log.
Your app (I assume pid 26010) tries to connect to the central heap profiler, but fails.
This is expected, it's a user (not userdebug) build: before android 12, apps could not connect to the central heap profiler.
07-11 21:25:10.915 I/perfetto(26010): malloc_hooks.cc:231 Constructing client for central daemon.
07-11 21:25:10.915 E/perfetto(26010): client.cc:121 Failed to connect to /dev/socket/heapprofd (errno: 13, Permission denied)
07-11 21:25:10.915 E/perfetto(26010): malloc_hooks.cc:238 Failed to connect to /dev/socket/heapprofd. This is benign on user builds.
07-11 21:25:10.915 I/perfetto(26010): malloc_hooks.cc:247 Setting up fork mode profiling.
So the app resorts to the "fork mode": it forks a process (pid 26036) that acts as its heap profiler:
07-11 21:25:11.022 I/perfetto(26036): approfd_producer.cc:166 Connected to the service, mode [child].
07-11 21:25:11.034 I/perfetto(26010): malloc_hooks.cc:461 com.levelinfinite.sgameGlobal: heapprofd_client initialized.
Now, as the heap profile grows, the forked process consumes more memory to keep track of everything. At some point some system daemon decides to kill the forked process:
07-11 21:25:42.108 I/Athena ( 5003): MemoryGuardAction: found orphan process [26036][1][10322]heapprofd(0)
07-11 21:25:42.110 I/Athena ( 5003): OppoClearSystemService : K [26036][10322][heapprofd(0), reason: 71
Immediately after that, your app reports the failure to write to the heap profiling ring buffer:
07-11 21:25:42.140 E/perfetto(26010): client.cc:393 Failed to write to shared ring buffer. Disconnecting. (errno: 104, Connection reset by peer)
07-11 21:25:42.140 E/perfetto(26010): client.cc:393 Failed to write to shared ring buffer. Disconnecting. (errno: 11, Try again)
In order to fix your problem:
1. Perhaps you could find a way to disable OppoClearSystemService? I'm afraid I can't help you much there, I think this is something that's Oppo specific.
2. You can upgrade to Android 12. On Android 12, apps are allowed to connect to the "central" heap profiling daemon. "fork mode" has been removed. This should hopefully allow you to capture longer heap profiles.