Android 5 (Lollipop) 에서 앱을 구동 시 메모리를 너무 많이 잡아먹는 이슈가 있어서 알아봤다.
HelloWorld 앱을 만들어 테스트를 했다.
링크: https://github.com/1004lucifer/Android_HelloWorld
다음과 같이 테스트를 진행했다.
Model: LG G2 (LG-F320K)
OS: Anroid 4.4.2
Runtime: ART 사용중 (Dalvik 선택 가능)
OS: Anroid 4.4.2
Runtime: ART 사용중 (Dalvik 선택 가능)
C:\Users\1004lucifer>adb shell dumpsys meminfo com.example.HelloWorld
Applications Memory Usage (kB):
Uptime: 62783906 Realtime: 111430475
** MEMINFO in pid 16346 [com.example.HelloWorld] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 0 0 0 0 4948 4283 172
Dalvik Heap 1737 1520 0 0 15793 15419 374
Dalvik Other 112 112 0 0
Stack 92 92 0 0
Other dev 584 580 4 0
.so mmap 1358 732 136 0
.apk mmap 80 0 12 0
.ttf mmap 4 0 0 0
.dex mmap 20 0 12 0
code mmap 595 0 100 0
image mmap 3387 552 1784 0
Other mmap 5 4 0 0
Unknown 1436 1428 0 0
TOTAL 9410 5020 2048 0 20741 19702 546
Objects
Views: 23 ViewRootImpl: 1
AppContexts: 3 Activities: 1
Assets: 3 AssetManagers: 3
Local Binders: 7 Proxy Binders: 15
Death Recipients: 0
OpenSSL Sockets: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
C:\Users\1004lucifer>
###### background ######
C:\Users\1004lucifer>adb shell dumpsys meminfo com.example.HelloWorld
Applications Memory Usage (kB):
Uptime: 62925311 Realtime: 111571881
** MEMINFO in pid 16346 [com.example.HelloWorld] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 0 0 0 0 4948 4220 203
Dalvik Heap 1737 1520 0 0 15793 15423 370
Dalvik Other 112 112 0 0
Stack 92 92 0 0
Other dev 480 476 4 0
.so mmap 1362 736 136 0
.apk mmap 80 0 12 0
.ttf mmap 4 0 0 0
.dex mmap 20 0 12 0
code mmap 617 0 116 0
image mmap 3356 556 1736 0
Other mmap 5 4 0 0
Unknown 1296 1288 0 0
TOTAL 9161 4784 2016 0 20741 19643 573
Objects
Views: 23 ViewRootImpl: 1
AppContexts: 3 Activities: 1
Assets: 3 AssetManagers: 3
Local Binders: 7 Proxy Binders: 14
Death Recipients: 0
OpenSSL Sockets: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
C:\Users\1004lucifer>
앱의 forground 상태와 background 상태가 크게 변화가 없었다.
(PSS 메모리 총 사용량 9MB 정도)
LG G Flex2 (LG-F510S)
OS: Anroid 5.0.1
Runtime: ART (default)
OS: Anroid 5.0.1
Runtime: ART (default)
C:\Users\1004lucifer>adb shell dumpsys meminfo com.example.HelloWorld
Applications Memory Usage (kB):
Uptime: 18681892 Realtime: 22459648
** MEMINFO in pid 21126 [com.example.HelloWorld] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 25050 24956 0 5128 36045 36045 4914
Dalvik Heap 701 596 0 13612 48612 15932 32680
Dalvik Other 552 552 0 4
Stack 192 192 0 0
Other dev 331 148 4 0
.so mmap 1532 132 300 2164
.apk mmap 133 0 0 0
.ttf mmap 2 0 0 0
.dex mmap 16 0 12 0
code mmap 1013 0 164 0
image mmap 1219 752 4 0
Other mmap 4 4 0 0
Graphics 21964 21964 0 0
GL 11716 11716 0 0
Unknown 16 16 0 76
TOTAL 64441 61028 484 20984 84657 51977 37594
Objects
Views: 12 ViewRootImpl: 1
AppContexts: 3 Activities: 1
Assets: 3 AssetManagers: 3
Local Binders: 8 Proxy Binders: 14
Death Recipients: 0
OpenSSL Sockets: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
C:\Users\1004lucifer>
shell@z2:/proc/21126 $ cat status
cat status
Name: mple.HelloWorld
State: S (sleeping)
Tgid: 21126
Pid: 21126
PPid: 449
TracerPid: 0
Uid: 10168 10168 10168 10168
Gid: 10168 10168 10168 10168
FDSize: 64
Groups: 9997 50168
VmPeak: 2261984 kB
VmSize: 2242700 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 74204 kB
VmRSS: 71892 kB
VmData: 173892 kB
VmStk: 8192 kB
VmExe: 16 kB
VmLib: 112836 kB
VmPTE: 760 kB
VmSwap: 20984 kB
Threads: 20
SigQ: 0/5873
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000001a04
SigIgn: 0000000000000000
SigCgt: 00000002000094f8
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000000000000000
Cpus_allowed: ff
Cpus_allowed_list: 0-7
voluntary_ctxt_switches: 745
nonvoluntary_ctxt_switches: 464
shell@z2:/proc/21126 $
###### background ######
C:\Users\1004lucifer>adb shell dumpsys meminfo com.example.HelloWorld
Applications Memory Usage (kB):
Uptime: 18740519 Realtime: 22518275
** MEMINFO in pid 21126 [com.example.HelloWorld] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 24998 24904 0 5128 35899 35899 5060
Dalvik Heap 601 496 0 13612 32196 15848 16348
Dalvik Other 504 504 0 4
Stack 184 184 0 0
Other dev 307 124 4 0
.so mmap 1532 132 300 2164
.apk mmap 133 0 0 0
.ttf mmap 2 0 0 0
.dex mmap 16 0 12 0
code mmap 1013 0 164 0
image mmap 1219 752 4 0
Other mmap 4 4 0 0
Graphics 13888 13888 0 0
GL 3896 3896 0 0
Unknown 16 16 0 76
TOTAL 48313 44900 484 20984 68095 51747 21408
Objects
Views: 12 ViewRootImpl: 1
AppContexts: 3 Activities: 1
Assets: 3 AssetManagers: 3
Local Binders: 8 Proxy Binders: 13
Death Recipients: 0
OpenSSL Sockets: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
C:\Users\1004lucifer>
shell@z2:/proc/21126 $ cat status
cat status
Name: mple.HelloWorld
State: S (sleeping)
Tgid: 21126
Pid: 21126
PPid: 449
TracerPid: 0
Uid: 10168 10168 10168 10168
Gid: 10168 10168 10168 10168
FDSize: 64
Groups: 9997 50168
VmPeak: 2261984 kB
VmSize: 2225708 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 74204 kB
VmRSS: 72080 kB
VmData: 172868 kB
VmStk: 8192 kB
VmExe: 16 kB
VmLib: 112836 kB
VmPTE: 744 kB
VmSwap: 20984 kB
Threads: 19
SigQ: 0/5873
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000001a04
SigIgn: 0000000000000000
SigCgt: 00000002000094f8
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000000000000000
Cpus_allowed: ff
Cpus_allowed_list: 0-7
voluntary_ctxt_switches: 762
nonvoluntary_ctxt_switches: 469
shell@z2:/proc/21126 $
forground
Pss total: 64MB
Heap Alloc: 16MB
Heap Free: 32MB
background
Pss total: 48MB
Heap Alloc: 16MB
Heap Free: 16MB
App 이 background 상태가 되자
여유 힙메모리가 많이 줄어있음을 알 수 있으며
Pss 사용량 측면에선 Graphics, GL 부분이 많이 줄어있었다.
Samsung Note4 S-LTE (SM-N916S)
OS: Anroid 5.0.1
Runtime: ART (default)
OS: Anroid 5.0.1
Runtime: ART (default)
C:\Users\1004lucifer>adb shell dumpsys meminfo com.example.HelloWorld
Applications Memory Usage (kB):
Uptime: 15118699 Realtime: 83655498
** MEMINFO in pid 15851 [com.example.HelloWorld] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 0 0 0 0 9286 9286 14265
Dalvik Heap 1906 1860 0 25512 43900 27593 16307
Dalvik Other 60 60 0 0
Stack 152 152 0 0
Other dev 4 0 4 0
.so mmap 378 116 4 1676
.apk mmap 84 0 8 0
.ttf mmap 15 0 0 0
.dex mmap 16 0 12 0
code mmap 476 0 68 0
image mmap 21065 648 19236 0
Other mmap 4 4 0 0
GL 25108 25108 0 0
Unknown 4911 4876 4 2896
TOTAL 54179 32824 19336 30084 53186 36879 30572
Objects
Views: 21 ViewRootImpl: 1
AppContexts: 3 Activities: 1
Assets: 3 AssetManagers: 3
Local Binders: 8 Proxy Binders: 19
Death Recipients: 0
OpenSSL Sockets: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
C:\Users\1004lucifer>
root@tre3calteskt:/proc/11411 # cat status
cat status
Name: mple.HelloWorld
State: S (sleeping)
Tgid: 11411
Pid: 11411
PPid: 2979
TracerPid: 0
Uid: 10336 10336 10336 10336
Gid: 10336 10336 10336 10336
FDSize: 256
Groups: 9997 50336
VmPeak: 1916172 kB
VmSize: 1898416 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 90840 kB
VmRSS: 89520 kB
VmData: 152668 kB
VmStk: 8192 kB
VmExe: 8 kB
VmLib: 85916 kB
VmPTE: 368 kB
VmSwap: 30024 kB
Threads: 24
SigQ: 0/22312
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000001204
SigIgn: 0000000000000000
SigCgt: 00000002000094f8
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000000000000000
Seccomp: 0
Cpus_allowed: ff
Cpus_allowed_list: 0-7
voluntary_ctxt_switches: 576
nonvoluntary_ctxt_switches: 117
root@tre3calteskt:/proc/11411 #
root@tre3calteskt:/proc/15851/fd # ls -l
ls -l
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 0 -> /dev/null
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 1 -> /dev/null
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 10 -> /system/framework/framework.jar
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 11 -> /system/framework/core-libart.jar
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 12 -> /dev/log/radio
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 13 -> /dev/log/main
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 14 -> /dev/log/events
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 15 -> /dev/log/system
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 16 -> /system/framework/framework-res.apk
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 17 -> /system/framework/twframework-res.apk
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 18 -> socket:[252558]
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 19 -> /dev/cpuctl/apps/tasks
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 2 -> /dev/null
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 20 -> /dev/cpuctl/apps/bg_non_interactive/tasks
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 21 -> /dev/alarm
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 22 -> socket:[250708]
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 23 -> pipe:[250709]
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 24 -> pipe:[250709]
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 25 -> pipe:[250713]
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 26 -> pipe:[250713]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 27 -> anon_inode:[eventpoll]
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 28 -> /data/app/com.example.HelloWorld-1/base.apk
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 3 -> /dev/log/main
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 30 -> pipe:[251593]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 31 -> socket:[250715]
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 32 -> pipe:[251593]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 33 -> anon_inode:[eventpoll]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 34 -> /dev/mali0
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 35 -> socket:[249776]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 36 -> anon_inode:dmabuf
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 37 -> /dev/ion
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 38 -> socket:[255450]
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 39 -> anon_inode:malitl_15851_0xaf85eb68
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 4 -> /dev/log/radio
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 40 -> anon_inode:malitl_15851_0xa0954a90
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 41 -> anon_inode:malitl_15851_0xa0954f20
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 43 -> socket:[249778]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 44 -> anon_inode:dmabuf
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 45 -> anon_inode:dmabuf
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 46 -> anon_inode:dmabuf
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 5 -> /dev/log/events
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 6 -> /dev/log/system
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 7 -> /sys/kernel/debug/tracing/trace_marker
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 8 -> /dev/__properties__
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 9 -> /dev/binder
root@tre3calteskt:/proc/15851/fd #
###### background ######
C:\Users\1004lucifer>adb shell dumpsys meminfo com.example.HelloWorld
Applications Memory Usage (kB):
Uptime: 12091340 Realtime: 80628140
** MEMINFO in pid 11411 [com.example.HelloWorld] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 0 0 0 0 9898 9898 14677
Dalvik Heap 1449 1412 0 25512 35709 27594 8115
Dalvik Other 52 52 0 0
Stack 160 160 0 0
Other dev 4 0 4 0
.so mmap 374 128 0 1668
.apk mmap 68 0 8 0
.ttf mmap 13 0 0 0
.dex mmap 8 0 8 0
code mmap 424 0 52 0
image mmap 11305 664 232 0
Other mmap 4 4 0 0
GL 10145 10145 0 0
Unknown 5363 5336 4 2844
TOTAL 29369 17901 308 30024 45607 37492 22792
Objects
Views: 21 ViewRootImpl: 1
AppContexts: 3 Activities: 1
Assets: 3 AssetManagers: 3
Local Binders: 8 Proxy Binders: 17
Death Recipients: 0
OpenSSL Sockets: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
C:\Users\1004lucifer>
root@tre3calteskt:/proc/15851 # cat status
cat status
Name: mple.HelloWorld
State: S (sleeping)
Tgid: 15851
Pid: 15851
PPid: 2979
TracerPid: 0
Uid: 10336 10336 10336 10336
Gid: 10336 10336 10336 10336
FDSize: 256
Groups: 9997 50336
VmPeak: 1916172 kB
VmSize: 1867472 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 89512 kB
VmRSS: 73592 kB
VmData: 150620 kB
VmStk: 8192 kB
VmExe: 8 kB
VmLib: 85916 kB
VmPTE: 336 kB
VmSwap: 30084 kB
Threads: 23
SigQ: 0/22312
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000001204
SigIgn: 0000000000000000
SigCgt: 00000002000094f8
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000000000000000
Seccomp: 0
Cpus_allowed: ff
Cpus_allowed_list: 0-7
voluntary_ctxt_switches: 383
nonvoluntary_ctxt_switches: 77
root@tre3calteskt:/proc/15851 #
root@tre3calteskt:/proc/15851/fd # ls -l
ls -l
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 0 -> /dev/null
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 1 -> /dev/null
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 10 -> /system/framework/framework.jar
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 11 -> /system/framework/core-libart.jar
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 12 -> /dev/log/radio
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 13 -> /dev/log/main
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 14 -> /dev/log/events
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 15 -> /dev/log/system
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 16 -> /system/framework/framework-res.apk
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 17 -> /system/framework/twframework-res.apk
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 18 -> socket:[252558]
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 19 -> /dev/cpuctl/apps/tasks
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 2 -> /dev/null
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 20 -> /dev/cpuctl/apps/bg_non_interactive/tasks
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 21 -> /dev/alarm
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 22 -> socket:[250708]
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 23 -> pipe:[250709]
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 24 -> pipe:[250709]
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 25 -> pipe:[250713]
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 26 -> pipe:[250713]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 27 -> anon_inode:[eventpoll]
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 28 -> /data/app/com.example.HelloWorld-1/base.apk
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 3 -> /dev/log/main
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 30 -> pipe:[251593]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 31 -> socket:[250715]
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 32 -> pipe:[251593]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 33 -> anon_inode:[eventpoll]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 34 -> /dev/mali0
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 35 -> socket:[249776]
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 36 -> anon_inode:dmabuf
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 37 -> /dev/ion
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 38 -> socket:[255450]
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 39 -> anon_inode:malitl_15851_0xaf85eb68
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 4 -> /dev/log/radio
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 40 -> anon_inode:malitl_15851_0xa0954a90
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 5 -> /dev/log/events
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 6 -> /dev/log/system
l-wx------ u0_a336 u0_a336 2015-03-26 17:22 7 -> /sys/kernel/debug/tracing/trace_marker
lr-x------ u0_a336 u0_a336 2015-03-26 17:22 8 -> /dev/__properties__
lrwx------ u0_a336 u0_a336 2015-03-26 17:22 9 -> /dev/binder
root@tre3calteskt:/proc/15851/fd #
rooting 된 단말이다 보니 /proc/{pid}/maps, /proc/{pid}/smaps 파일을 가져올 수 있었다.
https://www.mediafire.com/folder/q128u8s4a1b5zu9,1r9yxyal36gjy3u,sazdjdhb6zhdrhb,9e940s1s3bl8a9f/shared
forground
Pss total: 54MB
Heap Alloc: 27MB
Heap Free: 16MB
background
Pss total: 29MB
Heap Alloc: 27MB
Heap Free: 8MB
LG모델과 비슷하게 App 이 background 상태가 되자
여유 힙메모리가 많이 줄어있음을 알 수 있으며
Pss 사용량 측면에선 image mmap, GL 부분이 많이 줄어있었다.
분석
1. Heap Alloc 사용량 관련해서는 아래 링크의 내용대로 Android 5 (Lollipop) 에서의 힙메모리가 기본적으로 많이 사용되는 것은 확인 했었다.
링크: 힙덤프(Heap Memory Dump) 의 sPreloadedDrawables 객체 분석
2. Heap Free 메모리 사용량
Android 4.4 (KitKat)
forground 와 background 에서의 Heap Free 메모리의 차이가 크지 않았지만
Android 5 (Lollipop)
forground 와 background 에서의 Heap Free 메모리의 차이가 많이 나는 것을 알 수 있었다.
아마 App 사용중 Free Heap Memory 를 늘리려 하면 퍼포먼스 이슈로 인해 forground 에 있을 때에는 Heap Memory 를 미리 할당 하는게 아닐까 싶다.
forground 와 background 에서의 Heap Free 메모리의 차이가 크지 않았지만
Android 5 (Lollipop)
forground 와 background 에서의 Heap Free 메모리의 차이가 많이 나는 것을 알 수 있었다.
아마 App 사용중 Free Heap Memory 를 늘리려 하면 퍼포먼스 이슈로 인해 forground 에 있을 때에는 Heap Memory 를 미리 할당 하는게 아닐까 싶다.
3. Linux 모델의 메모리 주소 매핑파일인 maps, smaps 파일 확인
Samsung Note4 S-LTE (SM-N916S)
위 모델의 forground 상태의 maps, smaps 에서의 Pss 사용량을 보니 다음과 같았다.
1. /data/dalvik-cache/arm/system@framework@boot.art 라는 파일을 image 로 많은 Memory 할당량으로 사용중인 것을 볼 수 었다.
(image 부분으로 사용된 것은 링크 를 보고 추측을 하였다.)
2. /dev/ashmem/dalvik-non moving space (deleted) 부분에서 3.2MB 사용
3. libGLES_mali.so 파일 1.4MB 사용
위 모델의 forground 상태의 maps, smaps 에서의 Pss 사용량을 보니 다음과 같았다.
1. /data/dalvik-cache/arm/system@framework@boot.art 라는 파일을 image 로 많은 Memory 할당량으로 사용중인 것을 볼 수 었다.
(image 부분으로 사용된 것은 링크 를 보고 추측을 하였다.)
2. /dev/ashmem/dalvik-non moving space (deleted) 부분에서 3.2MB 사용
3. libGLES_mali.so 파일 1.4MB 사용
결론
Linux Memory 모델을 완벽히 이해하고 있는 것도 아니어서 단정지을 수 없지만
Android 5.0.1(Lollipop) 에서는 시스템자체에서 Memory를 많이 사용하는 것 같다.
(시스템 자체에서 많이 사용하는걸 어찌 하겠는가..;;)
Memory 사용량을 많이 줄인다고 해도 KitKat 과 비교를 한다면 한계가 분명히 있다.
시스템에서 꼭 필요한 부분을 줄일 수는 없지 않은가?
Android 5(Lollipop) 버전에서 Memory Leak 이슈가 있는 것은 알고있었지만 그건 Android 시스템 자체에서 사용하는 것으로 알고 있다.
(테스트를 많이 해본건 아니지만 App 자체에서 Memory Leak 이 발생하는 것 같지는 않았다.)
아래의 링크를 보면 Android Memory Leak 이슈와 함께 많은 사용자들이 App 에서 더 증가된 메모리를 사용중이라는 의견이 있다고 적혀있다.
http://www.phonearena.com/news/Google-acknowledges-leaky-memory-fix-coming-to-Android-5.1.1_id67236
===========================
2015.06.11 내용 추가
Android 5.1 에서 Memory Leak 이슈를 수정했다는 글이 있다.
위의 테스트 기기들은 Android 5.0.x 버전이다보니 Memory Leak 으로 인해 메모리 사용량이 높은 것으로 추정이 된다.
http://gadgets.ndtv.com/mobiles/news/android-51-lollipop-memory-leak-issue-fixed-internally-says-google-670960
메모리 이슈가 얼마나 심각했으면 Android 5.0 => Android 4.4 로 다운그레이드 방법이 나오기까지 했을까..ㅎ
http://www.techtimes.com/articles/50401/20150502/more-users-report-continuing-android-5-0-lollipop-problems-on-htc-one-m7-m8-freezing-apps-battery-drain-forced-reboots.htm
===========================
다음의 링크에서 도움을 얻었다.
Android 버전 별 Heap Memory 차이점
1. http://stackoverflow.com/questions/5350465/android-heap-size-on-different-phones-devices-and-os-versions
2. http://stackoverflow.com/questions/2630158/detect-application-heap-size-in-android
Android KitKat vs Lollipop 에 대한 Memory 사용량 관련
http://stackoverflow.com/questions/27617525/ram-usage-in-android-l-vs-kitkat
Linux Memory 모델 관련
https://techtalk.intersec.com/2013/07/memory-part-1-memory-types/
https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/
JAVA & Linux Memory 관련
http://novathin.kr/24
http://novathin.kr/25
댓글
댓글 쓰기