Is the memory returned by adb shell dumsys meminfo in kB or KB?
where:
kB = 1000 bytes
KB = 1024 bytes
It's KB (1024 bytes), or kibibytes (KiB), contrary to the kB notation in their printfs which is supposed to mean 1000 bytes as you noted.
Here's how I know. On my Linux box, if I do free -b,
total used free shared buffers cached
Mem: 67459153920 60865880064 6593273856 307834880 1373028352 40107618304
So look at the total value of 67459153920. That's in bytes (-b). Now if I look at meminfo,
MemTotal: 65878080 kB
and 67459153920 / 1024 = 65878080, so that value is in KB or aka KiB (1024 bytes).
https://en.wikipedia.org/wiki/Kilobyte
Note that I tested this on my Linux desktop because Android Linux doesn't happen to include the free command, but dumpsys meminfo is just reporting the results of cat /proc/meminfo which is implemented at the Linux kernel level of Android fs/proc/meminfo.c.
First of all this is not duplicate question and I have tried solutions from other similar threads but it looks like this case is different.
In my case I can successfully install and run other android project from the same emulator (x86 also tried arm) but this particular app project throws following error when installing also manually "adb install" from inside shell do not work either.
One of the error from log below is found (line number 232)
https://android.googlesource.com/platform/system/vold/+/froyo/Loop.cpp
However I do not know if the error "No content provider..." is related to the same error stack.
If it had the write-permission error (sdcard or file system permission like that) then other apps should also not install!
This problematic app is a NDK project with a custom content provider which I tried omitting but no avail. it seems like content provider error is related to apk installation from os and not really the content provider from within the app.
I am tired of testing with a real device, I am worried this would degrade my phones life because I had to do it very often.
--------- beginning of /dev/log/main
D/AndroidRuntime( 1977):
D/AndroidRuntime( 1977): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
W/linker ( 1977): libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
D/AndroidRuntime( 1977): CheckJNI is ON
D/dalvikvm( 1977): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 1977): Added shared lib libjavacore.so 0x0
D/dalvikvm( 1977): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 1977): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 1977): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 1977): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 1977): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 1977): failed to load memtrack module: -2
D/AndroidRuntime( 1977): Calling main entry com.android.commands.pm.Pm
E/PackageHelper( 1680): Failed to create secure container smdl2tmp1
--------- beginning of /dev/log/system
W/ActivityManager( 1149): No content provider found for permission revoke: file:///data/local/tmp/myapp.apk
E/Vold ( 932): Error creating imagefile (Read-only file system)
E/Vold ( 932): ASEC image file creation failed (Read-only file system)
W/Vold ( 932): Returning OperationFailed - no handler for errno 30
E/DefContainer( 1680): Failed to create container smdl2tmp1
W/ActivityManager( 1149): No content provider found for permission revoke: file:///data/local/tmp/myapp.apk
D/dalvikvm( 1149): GC_EXPLICIT freed 161K, 22% free 5442K/6948K, paused 1ms+1ms, total 8ms
D/AndroidRuntime( 1977): Shutting down VM
The problem might be either from:
an Android AOSP bug or a bug in the ROM you are using
(misconfiguration)
something has caused the partition where the apps installed on the SD Card (or an emulated internal card) are stored, to be read only
"Apps on SD card are stored in an encrypted container for platform security purposes -- so that other applications can not modify or corrupt them. When mounting the SD card, these containers are mounted so that they can be accessed in the same way as apps stored in internal storage."
On your stacktrace the problem is this:
E/Vold ( 932): Error creating imagefile (Read-only file system)
E/Vold ( 932): ASEC image file creation failed (Read-only file
system)
I've had a similar problem with an application that had defined in its AndroidManifest.xml the android:installLocation="preferExternal" and the following things worked for me (done independently of one another):
I/qtaguid ( 6299): Failed write_ctrl(u 40) res=-1 errno=22
I/qtaguid ( 6299): Untagging socket 40 failed errno=-22
W/NetworkManagementSocketTagger( 6299): untagSocket(40) failed with errno -22
D/Finsky ( 6299): [1] 2.onResponse: Verification id=29 response=0
D/Finsky ( 6299): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 29
E/Vold ( 127): Error creating imagefile (Read-only file system)
E/Vold ( 127): ASEC image file creation failed (Read-only file system)
W/Vold ( 127): Returning OperationFailed - no handler for errno 30
E/PackageHelper( 6280): Failed to create secure container smdl733025106.tmp
W/DefContainer( 6280): Failed to copy package at /storage/emulated/0/myapp.apk
W/DefContainer( 6280): java.io.IOException: Failed to create container smdl733025106.tmp
W/DefContainer( 6280): at com.android.defcontainer.DefaultContainerService.copyPackageToContainerInner(DefaultContainerService.java:327)
W/DefContainer( 6280): at com.android.defcontainer.DefaultContainerService.access$000(DefaultContainerService.java:67)
W/DefContainer( 6280): at com.android.defcontainer.DefaultContainerService$1.copyPackageToContainer(DefaultContainerService.java:108)
W/DefContainer( 6280): at com.android.internal.app.IMediaContainerService$Stub.onTransact(IMediaContainerService.java:60)
W/DefContainer( 6280): at android.os.Binder.execTransact(Binder.java:446)
As per https://developer.android.com/guide/topics/data/install-location.html change to android:installLocation="auto"
As per http://forum.xda-developers.com/showpost.php?p=58409922&postcount=4845 If you want to install it to "internal device storage", regardless of what the manifest says or what the system decides.
Go to Settings > Apps > Open the menu > Preferred install location >
set it to "Internal device storage". I had this set to "Let the system
decide". This caused some of the APKs to fail the install, because
they were marked to prefer the SD card as their installation location
and thus they tried to install onto the SD and it just failed. Now
that everything installs on the device, it works just fine.
If you want to install it to the "external storage"
adb root
adb shell
mount -o rw,remount rootfs /
chmod 777 /mnt/sdcard
pm install /mnt/sdcard/myapp.apk
mount -o ro,remount rootfs /
As per https://code.google.com/p/android/issues/detail?id=9593
&& http://www.androidpolice.com/2011/04/19/fixing-the-couldnt-install-on-usb-storage-or-sd-card-problem-on-android/
Only if you are able to find the smdl2tmp1.asec at the following paths
or you get error
smdl2tmp1 03-24 18:48:38.784: ERROR/Vold(86): ASEC file '/mnt/secure/asec/smdl2tmp1.asec' currently exists - destroy it first! (Address already in use)
adb root
adb shell rm /sdcard/.android_secure/smdl2tmp1.asec
adb shell rm /mnt/secure/asec/smdl2tmp1.asec
In my case I'm using a device with Android version 6, developing for Unity.
I am getting the same error when installing the app directly from the Unity Editor, this will not happen if i do upload the app to the android Game Play Developer console as a Beta version and then download and install it from there, in this case android will do needed encryption and install the app successfully.
My solution to do direct install was to set in the :
android build -> Player Settings > Install location -> to Force Internal
In addtion to #Mnemoinc's answer:
If you want to force the install to the "internal storage"
adb root
adb shell
pm install -f /sdcard/myapp.apk
This could be useful when using Cyanogenmod and having a secure storage.
I use an EC2 instance (Ubuntu), and I want launch gradlew in my Android project, through the Terminal.
But I have this error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not download artifact 'maven-ant-tasks.jar (org.apache.maven:maven-ant-tasks:2.1.3)'
> Failed to download resource 'https://jcenter.bintray.com/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar'.
> No space left on device
I checked the space, and Inodes and all is ok:
root#ip-xx-xx-xx-xx:/home/mytest/sandbox/MyApplication# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 99G 12G 83G 13% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 492M 12K 492M 1% /dev
tmpfs 100M 324K 99M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
overflow 1.0M 0 1.0M 0% /tmp
root#ip-xx-xx-xx-xx:/home/mytest/sandbox/MyApplication# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 6553600 241915 6311685 4% /
none 127032 2 127030 1% /sys/fs/cgroup
udev 125790 403 125387 1% /dev
tmpfs 127032 307 126725 1% /run
none 127032 1 127031 1% /run/lock
none 127032 1 127031 1% /run/shm
none 127032 2 127030 1% /run/user
overflow 127032 4 127028 1% /tmp
If I download manually this jar (maven-ant-tasks-2.1.3.jar) with wget command, the download is successful.
I tried with sudo privileges, and the same error appears (No space left on device).
Previously, I followed these explanations, to be sure about the space : EC2 instance on Amazon and I am greeted with "No space left on the disk". Again, the same error appears (No space left on device).
Thank you for your help guys!
I'm trying to change a Nexus 5 to use dm-verity module. For that I need to:
invoke an utility called veritysetup during boot before /system is mounted;
(this utility will will create a new device called /dev/mapper/devname);
let /system be mounted on /dev/mapper/devname, not the actual partition.
It looks like the mountpoint is configured on fstab.hammerhead (device/lge/hammerhead). In fact I have another mod working by changing this file. So this seams like the easy part.
I know some filesystems are mounted by init.c (system/core/init), like /dev and /proc, and some are mounted on init.hammerhead (system/core/rootdir), like /acct. But I can find where the request to mount /system is.
Any ideas?
That's not the correct way to do it. To use dm-verity we need to:
build android using "user" build type (default is "eng");
change fstab to include "verify" keyword on fs_mgr_flags.
So, when Android the vold module will find the verity flag and will create the mapper device.
If the system image has a signed hash table and precomputed hash and the root image has the public key everything should just work. We should find that the system partition was mounted on /dev/block/dm-0 instead of /dev/block/platform/msm_sdcc.1/by-name/system and is being verified while being read.
I am having a similar inquiry and the posted answer here is closest related post I have found, certaintly my inquiry is relavant...
Does anyone know where the code that generates or places the fstab files into the stage1 and stage2 boots is, I think there is a bug or missing file somewhere. I can easily change and update things. What file in AOSP actually needs to be edited before building in order to modify or make changes in the fstab file before it is packed into he ramfs stage 1 or stage 2. Also where do I place kernel debug parameters like "pci=nocrs" ?
*Note: The answer accepted here is the correct answer per the aosp source documentation, but it leaves out the same valuable information the source documentation does. Where does the file need to be placed in the tree before running the build I can see the output does have vendor folder with a couple versions of fstab, but I am not sure where it was placed in the boot images.
I would like to boot this in qemu kvm with the cuttlefish build.
Full kernel.log file here: https://pastebin.com/9MKFKeyN
Intresting part below:
[ 1.702829] init: Switching root to '/first_stage_ramdisk'
[ 1.703038] init: [libfs_mgr]ReadFstabFromDt(): failed to read fstab from dt
[ 1.703574] init: Using Android DT directory /proc/device-tree/firmware/android/
[ 1.712562] init: [libfs_mgr]Invalid ext4 superblock on '/dev/block/by-name/metadata'
[ 1.712864] traps: init[1] trap invalid opcode ip:41a6eb sp:7ffff59c93e0 error:0 in init[2f7000+200000]
[ 1.713197] init: InitFatalReboot: signal 4
[ 1.713574] init: #00 pc 000000000031b86b /init
[ 1.713626] init: Reboot ending, jumping to kernel
[ 1.713718] kvm: exiting hardware virtualization
[ 1.788726] reboot: Restarting system with command 'bootloader'
[ 1.788872] reboot: machine restart
Latest AOSP build as of 4/2/2022
buildprops
aosp/out/target/product/vsoc_x86_64/ramdisk/system/etc/ramdisk/build.prop
####################################
# from generate-common-build-props
# These properties identify this partition image.
####################################
ro.product.bootimage.brand=generic
ro.product.bootimage.device=vsoc_x86_64
ro.product.bootimage.manufacturer=Google
ro.product.bootimage.model=Cuttlefish x86_64 tv
ro.product.bootimage.name=aosp_cf_x86_64_tv
ro.bootimage.build.date=Sat Apr 2 12:06:36 CDT 2022
ro.bootimage.build.date.utc=1648919196
ro.bootimage.build.fingerprint=generic/aosp_cf_x86_64_tv/vsoc_x86_64:Tiramisu/AOSP.MASTER/me04021206:userdebug/test-keys
ro.bootimage.build.id=AOSP.MASTER
ro.bootimage.build.tags=test-keys
ro.bootimage.build.type=userdebug
ro.bootimage.build.version.incremental=eng.me.20220402.120943
ro.bootimage.build.version.release=12
ro.bootimage.build.version.release_or_codename=Tiramisu
ro.bootimage.build.version.sdk=32
# end of file
fstab.ext4
/genvol/aosp/out/target/product/vsoc_x86_64/recovery/root/first_stage_ramdisk/fstab.ext4
# Non-dynamic, boot critical partitions
/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect,first_stage_mount,avb=boot
/dev/block/by-name/init_boot /init_boot emmc defaults recoveryonly,slotselect,first_stage_mount,avb=init_boot
/dev/block/by-name/vendor_boot /vendor_boot emmc defaults recoveryonly,slotselect
system /system erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta_system,avb_keys=/avb
system /system ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system,avb_keys=/avb
# Add all non-dynamic partitions except system, after this comment
/dev/block/by-name/userdata /data ext4 nodev,noatime,nosuid,errors=panic latemount,wait,check,quota,formattable,fileencryption=aes-256-xts:aes-256-cts,keydirectory=/metadata/vold/metadata_encryption,checkpoint=block
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,errors=panic wait,formattable,first_stage_mount,check
/dev/block/by-name/misc /misc emmc defaults defaults
# Add all dynamic partitions except system, after this comment
odm /odm erofs ro wait,logical,first_stage_mount,slotselect,avb
odm /odm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
product /product erofs ro wait,logical,first_stage_mount,slotselect,avb
product /product ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
system_ext /system_ext erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
system_ext /system_ext ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
vendor /vendor erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta
vendor /vendor ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta
vendor_dlkm /vendor_dlkm erofs ro wait,logical,first_stage_mount,slotselect,avb
vendor_dlkm /vendor_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
odm_dlkm /odm_dlkm erofs ro wait,logical,first_stage_mount,slotselect,avb
odm_dlkm /odm_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
system_dlkm /system_dlkm erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta
system_dlkm /system_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta
# ZRAM, SD-Card and virtiofs shares
/dev/block/zram0 none swap defaults zramsize=75%
/dev/block/vdc1 /sdcard vfat defaults recoveryonly
/devices/*/block/vdc auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
shared /mnt/vendor/shared virtiofs nosuid,nodev,noatime nofail
I also have full kernel log and other information if it will help, Vtd and Vtx are working and all of the pci show in the IOMMU Groups.
acloud create --local-instance 1 --local-image tells me how to start troubleshooting when it fails, only after you manually build the certfile as that part of the acloud setup for instance1 cannot complete, I found that error, but have not yet fixed the source for it, that one was simple - Manually created the cert allowed it to proceed but fails at the switchroot in the boot. All the hardware and qemu all showed good.
A few points of interest as cannot add full kernel.log
Waiting for AVD(s) to boot up ...stop_cvd I 04-02 17:33:50 137759 137759 main.cc:162] Successfully stopped device cvd-1: 0.0.0.0:6520
Fail! (453s)
Total time: (453s)
Device summary:
Fail in:
Cannot create cuttlefish instance: Device did not boot within 450 secs. Stderr:
The following files contain useful debugging information:
Serial console is disabled; use -console=true to enable it.
Kernel log: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/kernel.log
Logcat output: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/logs/logcat
Launcher log: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/logs/launcher.log
Instance configuration: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/cuttlefish_config.json
Instance environment: /tmp/acloud_cvd_temp/local-instance-1/.cuttlefish.sh
Failed to read a complete exit code, read 0 bytes only instead of the expected 4
VIRTUAL_DEVICE_BOOT_FAILED
launch_cvd E 04-02 17:33:50 115944 115944 main.cc:252] run_cvd returned 10
For more detail: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/launcher.log
Encountered the following errors:
Cannot create cuttlefish instance: Device did not boot within 450 secs. Stderr:
The following files contain useful debugging information:
Serial console is disabled; use -console=true to enable it.
Kernel log: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/kernel.log
Logcat output: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/logs/logcat
Launcher log: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/logs/launcher.log
Instance configuration: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/cuttlefish_config.json
Instance environment: /tmp/acloud_cvd_temp/local-instance-1/.cuttlefish.sh
Failed to read a complete exit code, read 0 bytes only instead of the expected 4
VIRTUAL_DEVICE_BOOT_FAILED
launch_cvd E 04-02 17:33:50 115944 115944 main.cc:252] run_cvd returned 10
For more detail: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/launcher.log
If you have any question or need acloud team support, please feel free to contact us by email at buganizer-system+419709#google.com.
Line 227 of kernel log: [ 0.318334] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
I am making a live wallpaper app with libgdx in which I change the assets depending on the time. For. e.g from 6am to 6pm I have the "morning graphics" after that I have "evening graphics" from 6pm to 6am.
The way I have structured the Assets is as follows
I have 12 static arrays of type AtlasRegion 1 static Texture Region variable and 1 static texture variable.
I have two static functions loadMorning() and loadEvening() for loading the assets.
In the funcions I load as follows
For all arrays if they are not null do array.clear()
then load the regions. Dispose the TextureRegion variable and set texture variable to null before resetting their values.
The thing that is happening is that after every change of assets the memory seems to increasing
As a user's perepective I am using this app to see the memory
https://play.google.com/store/apps/details?id=mem.usage&hl=en
When I start my app for the first time .. it is showing as 68MB in the app ,
Day1 Morning Stats
Day 1
ID Heap Size Allocated Free %Used #Objects
1 10.812 MB 3.186 MB 7.626 MB 29.47% 45,405
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 0 0 0 0 16620 4285 38
Dalvik Heap 8692 8604 0 0 11072 3293 7779
Dalvik Other 1374 1216 0 0
Stack 96 96 0 0
Other dev 33016 4908 4 0
.so mmap 1266 692 136 0
.apk mmap 160 0 116 0
.dex mmap 287 20 8 0
Other mmap 5 4 0 0
Unknown 1431 1412 0 0
TOTAL 46327 16952 264 0 27692 7578 7817
Objects
Views: 1 ViewRootImpl: 0
AppContexts: 3 Activities: 0
Assets: 2 AssetManagers: 2
Local Binders: 11 Proxy Binders: 19
Death Recipients: 0
OpenSSL Sockets: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
Day 1 Evening Stats
adb log after evening assets are loaded
D/dalvikvm(2451): GC_FOR_ALLOC freed 1619K, 71% free 3281K/11072K, paused 14ms, total 15ms
D/dalvikvm(2451): GC_FOR_ALLOC freed 1517K, 71% free 3281K/11072K, paused 11ms, total 11ms
I/dalvikvm-heap(2451): Grow heap (frag case) to 6.548MB for 1331595-byte allocation
D/dalvikvm(2451): GC_CONCURRENT freed 1862K, 67% free 4127K/12376K, paused 2ms+2ms, total 13ms
D/dalvikvm(2451): GC_EXPLICIT freed 2384K, 74% free 3268K/12376K, paused 2ms+3ms, total 27ms
ID Heap Size Allocated Free %Used #Objects
1 10.816 MB 3.191 MB 7.625 MB 29.50% 45,525
This adb log right after change
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 0 0 0 0 16728 4346 29
Dalvik Heap 1654 1576 0 0 11076 3348 7728
Dalvik Other 1435 1296 0 0
Stack 100 100 0 0
Other dev 63332 32644 4 0
.so mmap 1110 692 116 0
.apk mmap 7 0 4 0
.dex mmap 586 20 368 0
Other mmap 5 4 0 0
Unknown 1504 1488 0 0
TOTAL 69733 37820 492 0 27804 7694 7757
Objects
Views: 1 ViewRootImpl: 0
AppContexts: 3 Activities: 0
Assets: 2 AssetManagers: 2
Local Binders: 10 Proxy Binders: 17
Death Recipients: 0
OpenSSL Sockets: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
The memory showing in the app is now 117MB
This keeps increasing , next morning the size shown in app is about 150 MB.
I need some pointers where to look to understand this better.
One remedy against resource leaks in the code that you cannot control is restarting the application. You either kill the process or do System.exit().
But before doing that, you have to schedule a restart.
Please note that although different android releases should all have been compatible, they are not compatible in application restart behavior. At least, v2.x and v4.0 did differ (in v2.x System.exit() caused application restart with the topmost activity closed), not sure about the latest releases.