Seva Alekseyev
Seva Alekseyev

Reputation: 61378

Ashmem retention policy

So on Android there's neither POSIX shared memory nor SysV shared memory, but there's ashmem. I want to use it to collect some postmortem info from crashes in the native subsystem (like in here). Question - can I make an ashmem region persist when the process that holds the handle to them dies? Where's ashmem documented?

Upvotes: 2

Views: 363

Answers (1)

Seva Alekseyev
Seva Alekseyev

Reputation: 61378

Looks like there's no builtin way to make a region stick. So I've built an out-of-process service, I pass a descriptor to a region to it, and hope the service outlives the main process. There's no lifetime guarantee for background services on Android, as everyone knows.

The service has a static variable of type ParcelFileDescriptor and supports two binder commands - GET and SET. They, respectively, return the said descriptor in the response parcel and assign it from the request parcel, closing the currently held one (if any).

Upvotes: 1

Related Questions