使用内存映射在 Android 中跨进程共享内存

Sharing memory across processes in Android using Memory-mapping

在浏览 android 内存管理文档时,我遇到了 Sharing memory across processes 的这个特定部分。

我无法理解这里的第二点:

Most static data is mmapped into a process. This technique allows data to be shared between processes, and also allows it to be paged out when needed. Example static data include: Dalvik code (by placing it in a pre-linked .odex file for direct mmapping), app resources (by designing the resource table to be a structure that can be mmapped and by aligning the zip entries of the APK), and traditional project elements like native code in .so files

我明白mmapping是什么了。在这一点上提到的东西是那个应用程序的 dalvik 代码,应用程序资源:为什么要与其他应用程序共享这些?

有人可以举一个例子说明这个说法是有意义的吗?

Dalvik 代码是您的应用程序的代码。这段代码是静态的,永远不会改变。此外,资源可以在进程之间共享,因为它们也是静态的并且永远不会改变。一个应用程序可能在不同的 OS 进程中具有不同的组件 运行。在这种情况下,共享所有应用程序代码和资源可以节省实际内存。