0

Allocating and using ashmem works well:

ashmemFD = open("/dev/ashmem", O_RDWR);
int ret = ioctl(ashmemFD, ASHMEM_SET_NAME, "vf");
ioctl(ashmemFD, ASHMEM_SET_SIZE, size);
ashmap = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, ashmemFD, 0);

But the question is, is it enough to just unmap it after use, or do I need to do more to release the memory again?

munmap((void*) ashmap,size);
user3387542
  • 611
  • 1
  • 8
  • 28

1 Answers1

1

You need to close all file descriptors to the ashmem region after unmapping it.

Ashmem regions can be seen as memory-based files handled by the kernel. As long as there is an open file descriptor to one of them, it will be kept in memory.

Hope this helps.

Digit
  • 2,073
  • 1
  • 13
  • 10