overview

command
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Example: sharedmem package overview

The ndk/sharedmem package provides Go bindings for Android's ASharedMemory API (available since API level 26).

ASharedMemory enables creating and managing anonymous shared memory regions that can be shared between processes via file descriptors. This is useful for zero-copy IPC, large data transfers between services, and sharing buffers with the Android framework.

Typical workflow:

  1. Create a shared memory region: ASharedMemory_create(name, size)
  2. Get the file descriptor for sharing
  3. Map into process address space with mmap()
  4. Share the fd with another process (via Binder/socket)
  5. The other process mmaps the same fd
  6. Both processes read/write the shared region
  7. Set protection with ASharedMemory_setProt() to make read-only

The underlying ASharedMemory functions operate on file descriptors (int), not opaque handles.

This program must run on an Android device with API level 26+.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL