Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问当前工程支持Android 15版本的16k内存分页么? #5657

Open
AmoryPepelu opened this issue Aug 28, 2024 · 0 comments
Open

请问当前工程支持Android 15版本的16k内存分页么? #5657

AmoryPepelu opened this issue Aug 28, 2024 · 0 comments

Comments

@AmoryPepelu
Copy link

detail | 详细描述 | 詳細な説明

### 检查引用特定页面大小的代码实例
即使您的应用是 16 KB 对齐的,如果将 会假定设备使用的是特定的页面大小。为了避免这种情况 请完成以下步骤:

移除所有引用 PAGE_SIZE的硬编码依赖项 常量或实例,它假定设备的页面 大小为 4 KB (4096)。

请改用 getpagesize()或 sysconf(_SC_PAGESIZE)。

查看是否使用了 mmap()和其他需要页面对齐的 API 参数,并在必要时替换为替代参数。

在某些情况下,如果您的应用将 PAGE_SIZE 作为一个不方便使用的值, 与底层页面大小相关联,那么这不会导致应用中断 (当使用 16 KB 模式时)。
不过,如果将该值传递给内核, 对于不带 MAP_FIXED 的 mmap,内核仍会使用整个页面, 会浪费一些内存因此,当大小为 16 KB 时,未定义 PAGE_SIZE。 模式在 NDK r27 及更高版本中启用。

如果您的应用以这种方式使用 PAGE_SIZE,并且从未将此值直接传递给 则不使用 PAGE_SIZE,而是创建一个具有新变量的新变量 表明相应名称已用于其他用途,并不反映真实情况 内存页。

具体可以查看:
https://developer.android.com/guide/practices/page-sizes?hl=zh-cn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant