[Android Q&A, Help & Troubleshooting] rightback:
I purchased a TV Box with the following description: MXQ 4K RK3229 Smart TV Box Android 5.1 1G/8G

I shouldn't really be saying no multitasking, as clearly some things are running concurrently...just not apps.

The problem I'm having is that, I can install and use an app (a telnet server, let's say) which works fine while it's in the foreground, but the task is killed when I leave the app by pressing the home button or switching to another window. By killed, I mean that the window is still available to use from the task chooser, but the telnet session dies at the client end and you can see, when the window is activated again, the telnet server reestablishing a listening port so I can start another client.

From googling, it sounds like this may well be caused by low RAM, but I'm thinking there should be plenty free and the various tools I'm using to investigate are giving me confusing results.

By the way, this telnet app works fine on my phone (with 2GB RAM)...a client session can be used as I switch apps and I see a little notification icon in the top corner (which doesn't appear on my TV display). Also, this behavior seems to apply to every app I run...a VPN, ES File Explorer, various memory utility apps...they all seem to reinitialize when I return to them.

I ran logcat in the background using logcat > /sdcard/myfiles/logcatlog.txt & to see what happens when my process dies. Here's the output that seems relevant:

W/ResourceType( 728): No package identifier when getting value for resource number 0x00000000
W/PackageManager( 728): Failure retrieving resources for com.waxrain.telnetd: Resource ID #0x0
I/ActivityManagerService( 503): Killing 13491:com.waxrain.telnetd/u0a77 (adj 0): user request after error
I/libprocessgroup( 503): Killing pid 13521 in uid 10077 as part of process group 13491
I/libprocessgroup( 503): Killing pid 13548 in uid 10077 as part of process group 13491
I/libprocessgroup( 503): Killing pid 14112 in uid 10077 as part of process group 13491
I/libprocessgroup( 503): Killing pid 14116 in uid 10077 as part of process group 13491
I/libprocessgroup( 503): Killing pid 14112 in uid 10077 as part of process group 13491
I/WindowState( 503): WIN DEATH: Window{353ca22b u0 com.waxrain.telnetd/com.waxrain.ui.TelnetdSetting

Now, that doesn't necessarily point to a memory issue, but

a) Other threads I've read about "failure retrieving resources..." point to memory issues

b) The lack of multitasking I'm describing often points to memory issues

c) I get the same error with the other apps I mentioned earlier

So, here's a dumpsys meminfo output:

root@rk322x_box:/sdcard/dennis # dumpsys meminfo

Applications Memory Usage (kB):
Uptime: 81253618 Realtime: 81253618

Total PSS by process:
53117 kB: com.google.android.gms.persistent (pid 964)
44933 kB: system (pid 503)
37602 kB: com.android.systemui (pid 728 / activities)
31411 kB: com.google.android.googlequicksearchbox:search (pid 2547)
24042 kB: com.amlogic.mediaboxlauncher (pid 1044 / activities)
13565 kB: zygote (pid 188)
13033 kB: com.android.phone (pid 1026)
12194 kB: android.process.media (pid 987)
11101 kB: com.android.inputmethod.latin (pid 876)
8901 kB: com.adups.fota (pid 4308)
7887 kB: com.waxrain.telnetd (pid 6872 / activities)
6950 kB: mediaserver (pid 159)
6565 kB: android.rockchip.update.service (pid 3583)
5472 kB: com.android.smspush (pid 1248)
2227 kB: surfaceflinger (pid 135)
2045 kB: logd (pid 129)
1498 kB: drmserver (pid 158)
1350 kB: wpa_supplicant_icomm (pid 1082)
1024 kB: sdcard (pid 189)
827 kB: vold (pid 134)
621 kB: keystore (pid 162)
619 kB: netd (pid 155)
528 kB: rild (pid 157)
378 kB: displayd (pid 133)
362 kB: lmkd (pid 131)
360 kB: /init (pid 1)
325 kB: tmp-mksh (pid 11997)
302 kB: ueventd (pid 111)
294 kB: daemonsu:0:11886 (pid 11889)
287 kB: dumpsys (pid 12052)
257 kB: dhcpcd (pid 1268)
249 kB: sh (pid 11882)
245 kB: sh (pid 154)
245 kB: daemonsu:10064 (pid 2214)
244 kB: debuggerd (pid 156)
237 kB: installd (pid 160)
216 kB: servicemanager (pid 132)
213 kB: adbd (pid 6908)
210 kB: su (pid 11886)
206 kB: daemonsu:0 (pid 7151)
196 kB: healthd (pid 130)
176 kB: busybox (pid 6901)
172 kB: daemonsu:master (pid 259)
153 kB: daemonsu:mount:master (pid 200)
147 kB: wdog (pid 6897)

Total PSS by OOM adjustment:
36728 kB: Native
13565 kB: zygote (pid 188)
6950 kB: mediaserver (pid 159)
2227 kB: surfaceflinger (pid 135)
2045 kB: logd (pid 129)
1498 kB: drmserver (pid 158)
1350 kB: wpa_supplicant_icomm (pid 1082)
1024 kB: sdcard (pid 189)
827 kB: vold (pid 134)
621 kB: keystore (pid 162)
619 kB: netd (pid 155)
528 kB: rild (pid 157)
378 kB: displayd (pid 133)
362 kB: lmkd (pid 131)
360 kB: /init (pid 1)
325 kB: tmp-mksh (pid 11997)
302 kB: ueventd (pid 111)
294 kB: daemonsu:0:11886 (pid 11889)
287 kB: dumpsys (pid 12052)
257 kB: dhcpcd (pid 1268)
249 kB: sh (pid 11882)
245 kB: sh (pid 154)
245 kB: daemonsu:10064 (pid 2214)
244 kB: debuggerd (pid 156)
237 kB: installd (pid 160)
216 kB: servicemanager (pid 132)
213 kB: adbd (pid 6908)
210 kB: su (pid 11886)
206 kB: daemonsu:0 (pid 7151)
196 kB: healthd (pid 130)
176 kB: busybox (pid 6901)
172 kB: daemonsu:master (pid 259)
153 kB: daemonsu:mount:master (pid 200)
147 kB: wdog (pid 6897)
44933 kB: System
44933 kB: system (pid 503)
49796 kB: Persistent
37602 kB: com.android.systemui (pid 728 / activities)
12194 kB: android.process.media (pid 987)
7887 kB: Foreground
7887 kB: com.waxrain.telnetd (pid 6872 / activities)
53117 kB: Visible
53117 kB: com.google.android.gms.persistent (pid 964)
11101 kB: Perceptible
11101 kB: com.android.inputmethod.latin (pid 876)
24042 kB: Home
24042 kB: com.amlogic.mediaboxlauncher (pid 1044 / activities)
59910 kB: B Services
31411 kB: com.google.android.googlequicksearchbox:search (pid 2547)
13033 kB: com.android.phone (pid 1026)
8901 kB: com.adups.fota (pid 4308)
6565 kB: android.rockchip.update.service (pid 3583)
5472 kB: Cached
5472 kB: com.android.smspush (pid 1248)

Total PSS by category:
94959 kB: Dalvik
38540 kB: .dex mmap
35844 kB: Native
32097 kB: .so mmap
28857 kB: .oat mmap
22870 kB: .art mmap
19911 kB: Dalvik Other
8200 kB: .apk mmap
3862 kB: Stack
3532 kB: Other mmap
2928 kB: Unknown
1271 kB: .ttf mmap
103 kB: Other dev
8 kB: .jar mmap
4 kB: Cursor
0 kB: Ashmem
0 kB: Gfx dev
0 kB: EGL mtrack
0 kB: GL mtrack
0 kB: Other mtrack

Total RAM: 1023052 kB (status critical)
Free RAM: 588440 kB (5472 cached pss + 511656 cached kernel + 71312 free)
Used RAM: 379654 kB (287514 used pss + 92140 kernel)
Lost RAM: 54958 kB
ZRAM: 4 kB physical used for 0 kB in swap (65532 kB total swap)
Tuning: 192 (large 512), oom 184320 kB, restore limit 61440 kB (low-ram)

It looks to me like there's plenty of RAM, but why status critical (it's at the bottom of the output)?

Below is the contents of /proc/meminfo. OK, MemFree is only 70MB, but that still seems like plenty and if the system needs more RAM wouldn't it just get it from the Cached memory?

root@rk322x_box:/sdcard/dennis # cat /proc/meminfo
MemTotal: 1023052 kB
MemFree: 71460 kB
Buffers: 33484 kB
Cached: 590856 kB
SwapCached: 0 kB
Active: 312072 kB
Inactive: 492888 kB
Active(anon): 63480 kB
Inactive(anon): 119200 kB
Active(file): 248592 kB
Inactive(file): 373688 kB
Unevictable: 1824 kB
Mlocked: 0 kB
HighTotal: 491516 kB
HighFree: 9044 kB
LowTotal: 531536 kB
LowFree: 62416 kB
SwapTotal: 65532 kB
SwapFree: 65532 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 182532 kB
Mapped: 112672 kB
Shmem: 236 kB
Slab: 33644 kB
SReclaimable: 15200 kB
SUnreclaim: 18444 kB
KernelStack: 4216 kB
PageTables: 6336 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 577056 kB
Committed_AS: 11903440 kB
VmallocTotal: 499712 kB
VmallocUsed: 46652 kB
VmallocChunk: 353280 kB

Finally, procrank:

PID Vss Rss Pss Uss cmdline
964 965164K 78848K 51124K 47132K com.google.android.gms.persistent
503 1461940K 74872K 44970K 38204K system_server
728 1541212K 71268K 38120K 31220K com.android.systemui
2547 1517436K 60792K 31529K 26728K com.google.android.googlequicksearchbox:search
1044 1494576K 55096K 27304K 22932K com.amlogic.mediaboxlauncher
188 1467992K 47472K 13692K 6400K zygote
1026 840088K 38764K 13159K 10072K com.android.phone
987 829952K 39064K 12319K 8968K android.process.media
876 830928K 36800K 11220K 8444K com.android.inputmethod.latin
4308 824616K 31896K 9021K 6792K com.adups.fota
6872 839252K 34400K 8029K 4512K com.waxrain.telnetd
159 43268K 10468K 6978K 5724K /system/bin/mediaserver
3583 823196K 27376K 6683K 4668K android.rockchip.update.service
1248 820896K 24196K 5593K 3948K com.android.smspush
135 71424K 4272K 2247K 1668K /system/bin/surfaceflinger
129 7968K 2652K 2051K 2012K /system/bin/logd
158 11924K 3852K 1517K 980K /system/bin/drmserver
1082 4456K 2632K 1361K 1192K /system/bin/wpa_supplicant_icomm
189 4132K 1336K 1026K 1016K /system/bin/sdcard
134 6892K 2040K 842K 696K /system/bin/vold
162 4320K 1736K 632K 520K /system/bin/keystore
155 10768K 1260K 624K 560K /system/bin/netd
157 5324K 1256K 538K 488K /system/bin/rild
133 6432K 964K 382K 336K /system/bin/displayd
131 2372K 1096K 370K 256K /system/bin/lmkd
1 792K 504K 360K 256K /init
11997 1116K 560K 327K 320K tmp-mksh
11889 5172K 684K 308K 176K daemonsu:0:11886
111 740K 408K 302K 200K /sbin/ueventd
12212 1056K 552K 284K 276K procrank
1268 1104K 600K 259K 244K /system/bin/dhcpcd
2214 3124K 500K 258K 224K daemonsu:10064
156 1804K 736K 251K 224K /system/bin/debuggerd
11882 1112K 556K 251K 172K /system/bin/sh
154 1112K 552K 247K 168K /system/bin/sh
160 1168K 592K 241K 228K /system/bin/installd
7151 5164K 556K 219K 92K daemonsu:0
132 1236K 560K 219K 204K /system/bin/servicemanager
6908 4636K 236K 213K 212K /sbin/adbd
11886 1060K 472K 212K 204K su
130 1588K 200K 196K 196K /sbin/healthd
259 3124K 432K 185K 148K daemonsu:master
6901 980K 308K 176K 172K /data/data/com.waxrain.telnetd/files/busybox
200 1060K 392K 166K 136K daemonsu:mount:master
6897 960K 272K 147K 144K /data/data/com.waxrain.telnetd/files/wdog
------ ------ ------
296171K 239464K TOTAL

RAM: 1023052K total, 69368K free, 33940K buffers, 590884K cached, 236K shmem, 33848K slab

As a last bit of info, in the logcat (which probably ran for less than 5 minutes) there are lowmemorykiller messages but I don't know if they mean anything important

E/lowmemorykiller( 131): Error opening /proc/14301/oom_score_adj; errno=2
E/lowmemorykiller( 131): Error opening /proc/14350/oom_score_adj; errno=2
E/lowmemorykiller( 131): Error opening /proc/14399/oom_score_adj; errno=2
E/lowmemorykiller( 131): Error opening /proc/14422/oom_score_adj; errno=2
E/lowmemorykiller( 131): Error opening /proc/14470/oom_score_adj; errno=2
E/lowmemorykiller( 131): Error opening /proc/14493/oom_score_adj; errno=2

I've tried a few memory tool apps and have tried setting the OOM level for the telnet PID to -16 and some other stuff like a swap file on an sdcard (but I never had much faith in that one...I don't think the OS used it).

Thanks for any suggestions or insight.