-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix Anroid 5 ~ 7 虚拟机堆内存减半方案存在的BUG #850
base: master
Are you sure you want to change the base?
Conversation
chengjian.scj seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
…e or space2Size always smaller than "dalvik.vm.heapsize"‘s value
Android 6级以上 "dalvik.vm.heapsize" property值不大于(大多数都为小于)虚拟机堆内存大小。 |
实际测试得出的结论: Android 6.0 SONY F3111型号 Android 7.0 XIAOMI MIX型号 |
理解你的意思了,应该是前面的表述说反了,实际是单个space的虚拟内存占用不大于dalvik.vm.heapsize。这个确实是art的设计,对于非largeHeap的App,启动时会通过Heap::ClampGrowthLimit缩减虚拟内存到growth_limit_,只是一般大型App都开了largeHeap。 |
🙏提醒,已更正 |
dev分支编译不过,直接在master分支操作了。
(1)Android 5.x space name相同
![image](https://private-user-images.githubusercontent.com/44021277/246306058-38bacda3-e3f4-4602-b10c-55a718c7a83e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NjIzOTUsIm5iZiI6MTcyNTc2MjA5NSwicGF0aCI6Ii80NDAyMTI3Ny8yNDYzMDYwNTgtMzhiYWNkYTMtZTNmNC00NjAyLWIxMGMtNTVhNzE4YzdhODNlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZ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BtAOWpP8BSN0-wa1rrhl170wmIK2aFi1BM)
![image](https://private-user-images.githubusercontent.com/44021277/246306090-ccc0e990-24b6-44b6-9847-8276c4a3bc6c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NjIzOTUsIm5iZiI6MTcyNTc2MjA5NSwicGF0aCI6Ii80NDAyMTI3Ny8yNDYzMDYwOTAtY2NjMGU5OTAtMjRiNi00NGI2LTk4NDctODI3NmM0YTNiYzZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDAyMjEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM5OWE4MTc1ODNmZDZjMjBhZGZhM2ExMWM0MzcyZjk1NDA4YmQ2NWJiM2M5Yzc0MGZkODExYTY3YjJmM2YzNzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.enQpK42hzLrDqFAx5Jwt7AatTU94tFUUPxGk5zNOUG0)
https://cs.android.com/android/platform/superproject/+/android-5.0.0_r1.0.1:art/runtime/gc/heap.cc
https://cs.android.com/android/platform/superproject/+/android-5.1.1_r9:art/runtime/gc/heap.cc
从上可以看出:
Android 5.x 系列Android系统存在一个BUG,即From和To的space name都是dalvik-main space(Android 5以上To的space name为dalvik-main space 1),因此Android 5.x 需要特殊处理。
(2)"dalvik.vm.heapsize" property值
Android 5.x 单个space的虚拟内存等于dalvik.vm.heapsize。
Android 6以上 单个space的虚拟内存不大于dalvik.vm.heapsize。
(3)IterateMaps存在fd泄漏
(4)ScopedCleaner移动构造函数内"omit"拼写错误
(5)IterateMaps中sscanf使用错误
![image](https://private-user-images.githubusercontent.com/44021277/249017055-6a38dcc2-c467-427c-8278-dcc1ce5e0a25.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NjIzOTUsIm5iZiI6MTcyNTc2MjA5NSwicGF0aCI6Ii80NDAyMTI3Ny8yNDkwMTcwNTUtNmEzOGRjYzItYzQ2Ny00MjdjLTgyNzgtZGNjMWNlNWUwYTI1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDAyMjEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNkMzZmZWI0ZGRmY2FmNzU5YWQ5ODhlMDcxOTQ2NGJhYzQ3Y2YzYzY3NTEyNmM3YTM4Zjc2MzFmYzRmZmE1NjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.U9v6Vt1WSxiu2J2yC7Ws-XmpR9GlIdsTsOP4YtyZk-o)
![image](https://private-user-images.githubusercontent.com/44021277/249017064-28fdd983-1f65-4177-ad58-70ab3fa558cd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NjIzOTUsIm5iZiI6MTcyNTc2MjA5NSwicGF0aCI6Ii80NDAyMTI3Ny8yNDkwMTcwNjQtMjhmZGQ5ODMtMWY2NS00MTc3LWFkNTgtNzBhYjNmYTU1OGNkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDAyMjEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgzZDVkMTVlZTdjODBiNTI5ZmQ0ZGE1MWZlOTNjZDJlZGEyZjNmZTJhYTYwYWUwZmYzNzc2ZGNkMWNjNzE2ZDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.eJXmFfuYGZ83lhyCTtsXMDDhbAxdTjbw3cX2bAJ8yjA)
s要求the terminating NUL character,如果使用s,则至少是4+1大小。
c不要求the terminating NUL character,如果使用c,则至少是4大小。
(6) pathLen是size_t类型,一定>=0,但会进行[pathLen-1]数组下标访问,pathLen必须>0
(7)适配 Android 5.0 TCL P590L机型
通常From和To在maps中为4条
//From
start:0x12c00000 end:0x12e01000 path:/dev/ashmem/dalvik-main space (deleted)
start:0x12e01000 end:0x22c00000 path:/dev/ashmem/dalvik-main space (deleted)
//To
start:0x22c00000 end:0x22c01000 path:/dev/ashmem/dalvik-main space (deleted)
start:0x22c01000 end:0x32c00000 path:/dev/ashmem/dalvik-main space (deleted)
Android 5.0 TCL P590L机型为5条
//From
start:0x12c00000 end:0x12c71000 path:/dev/ashmem/dalvik-main space (deleted)
start:0x12c71000 end:0x12e71000 path:/dev/ashmem/dalvik-main space (deleted)
start:0x12e71000 end:0x1bc00000 path:/dev/ashmem/dalvik-main space (deleted)
//To
start:0x1bc00000 end:0x1bc01000 path:/dev/ashmem/dalvik-main space (deleted)
start:0x1bc01000 end:0x24c00000 path:/dev/ashmem/dalvik-main space (deleted)
假设还可能存在下列情况:
//From
start:0x12c00000 end:0x12c01000 path:/dev/ashmem/dalvik-main space (deleted)
start:0x12c01000 end:0x1bc00000 path:/dev/ashmem/dalvik-main space (deleted)
//To
start:0x1bc00000 end:0x1bc71000 path:/dev/ashmem/dalvik-main space (deleted)
start:0x1bc71000 end:0x1be71000 path:/dev/ashmem/dalvik-main space (deleted)
start:0x1be71000 end:0x24c00000 path:/dev/ashmem/dalvik-main space (deleted)
“Adptor for Android 5.0 TCL P590L” commit做了相关BUG修复。
验证机型
Android5.0
SAMSUNG SM-N9005
SAMSUNG SM-N9000Q
SAMSUNG SM-T807V
LGE LG-H422
MOTOROLA XT1078
Android5.1
SAMSUNG SM-A510M
SAMSUNG SM-G928F
SAMSUNG SM-J111F
OPPO A37f
BLACKBERRY STV100-1
Android6.0
VIVO Y67A
MEIZU MEIZU_M5
SONY F3311
HUAWEI VNS-AL00
XIAOMI Redmi Note 3
SAMSUNG SM-G930F
SAMSUNG SM-A700F
Android7.0
XIAOMI MIX
SAMSUNG SM-G955U
HUAWEI VKY-L09
HTC 10
MOTOROLA Moto G (4)
SONY F8331
OUKITEL C8
WHEATEK KIICAA POWER
Android7.1
ONEPLUS A5010
SONY G8141
XIAOMI Redmi 5
SAMSUNG SM-A730F
OPPO CPH1727
MEIZU MX6
LGE LG-M700