Android NDK shared memory: how to use ashmem_create_region? -


I have found some guidelines on using shared memory in Ansroid OS. I have learned that OS or user-compelled killing procedures Because of memory leaks, shm_open is not present in the Android. Ashmem functions have been developed instead, but I can not get the announcement of ashmem_create_region () and other functions in my NDK. With so many things in Android, the answer is that to use JNI. Java class wraps java.nio.mappedByteBuffer ashmem and provides read / write methods to read it.

Unfortunately, if you are using shared memory to boost performance, many round trips through JNI are not attractive. To get the Askem handle by name, there is a reflection of the Cedric Fung, which will work, but breaks into the future structure. (It seems, BTW. It seems that someone has decided that "MFD" is very vague and "mfile descriptor" will be a better name, or something like that.) If you want to play with fire, According to the type instead of the name, because there is not much chance to change the type.

Cedric also proposes to implement a binder in C ++, but it takes you back where you start because the binder is not included in the NDK. Instead, you have to pass the handle through a binding service implemented in Java.

This is a lot of work for a simple feature, I know. It is easy to mmap just one file and instead it is used, which is very bad because the original file mapping is not nearly as mobile-friendly. : - (

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -