android emulator /proc/meminfo does not show the right value - android

I have an android application which enables some features only when the device has 512MB of RAM or more. This application reads the memtotal from /proc/meminfo (from Native C++ code) to determine the RAM size of the device.
I'm trying to install this application in an emulator running Android 4.1. I've set the RAM size of this emulator to 1024 and still the memtotal just shows 516312 KB. I have tried to increase the RAM size to 1536 (1.5GB) and still memtotal value remains the same in the meminfo file. I understand some memory is reserved for Kernel and some predefined bits. But missing a whole GB of memory left me clueless. Below is my meminfo file.
MemTotal: 516312 kB
MemFree: 282584 kB
Buffers: 1056 kB
Cached: 105976 kB
SwapCached: 0 kB
Active: 141696 kB
Inactive: 75880 kB
Active(anon): 122328 kB
Inactive(anon): 0 kB
Active(file): 19368 kB
Inactive(file): 75880 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 110560 kB
Mapped: 57468 kB
Slab: 5080 kB
SReclaimable: 1568 kB
SUnreclaim: 3512 kB
PageTables: 4132 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 258156 kB
Committed_AS: 1898016 kB
VmallocTotal: 450560 kB
VmallocUsed: 20564 kB
VmallocChunk: 423940 kB

Related

Why do I get an MobSF Error during setup?

installing (run.bat) MobSF I have this error during installation on a Win10. I have c++ insalled. Do you have any idea why this breaks?
run.bat of MobSF
Thanks.
I have tried running "clean.bat", installing C++ and insstalling SDK
Microsoft Windows [Versión 10.0.19044.2604]
(c) Microsoft Corporation. Todos los derechos reservados.
C:\Users\DAS>cd C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF
C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF>./setup.bat
"." no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF>setup.bat
[INSTALL] Checking for Python version 3.8+
[INSTALL] Found Python 3.10.4
[INSTALL] Found pip
Requirement already satisfied: pip in c:\users\das\appdata\local\programs\python\python310\lib\site-packages (23.0.1)
[INSTALL] Found OpenSSL executable
[INSTALL] Found Visual Studio Build Tools
[INSTALL] Creating venv
Requirement already satisfied: pip in c:\users\das\desktop\k\pentesting android\mobile-security-framework-mobsf\venv\lib\site-packages (22.0.4)
Collecting pip
Using cached pip-23.0.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
Successfully uninstalled pip-22.0.4
Successfully installed pip-23.0.1
[INSTALL] Installing Requirements
Collecting wheel
Downloading wheel-0.38.4-py3-none-any.whl (36 kB)
Installing collected packages: wheel
Successfully installed wheel-0.38.4
Ignoring gunicorn: markers 'platform_system != "Windows"' don't match your environment
Collecting Django>=3.1.5
Downloading Django-4.1.7-py3-none-any.whl (8.1 MB)
---------------------------------------- 8.1/8.1 MB 12.0 MB/s eta 0:00:00
Collecting lxml>=4.6.2
Downloading lxml-4.9.2-cp310-cp310-win_amd64.whl (3.8 MB)
---------------------------------------- 3.8/3.8 MB 12.7 MB/s eta 0:00:00
Collecting rsa>=4.7
Downloading rsa-4.9-py3-none-any.whl (34 kB)
Collecting biplist>=1.0.3
Downloading biplist-1.0.3.tar.gz (21 kB)
Preparing metadata (setup.py) ... done
Collecting requests>=2.25.1
Downloading requests-2.28.2-py3-none-any.whl (62 kB)
---------------------------------------- 62.8/62.8 kB ? eta 0:00:00
Collecting bs4>=0.0.1
Downloading bs4-0.0.1.tar.gz (1.1 kB)
Preparing metadata (setup.py) ... done
Collecting colorlog>=4.7.2
Downloading colorlog-6.7.0-py2.py3-none-any.whl (11 kB)
Collecting macholib>=1.14
Downloading macholib-1.16.2-py2.py3-none-any.whl (38 kB)
Collecting whitenoise>=5.2.0
Downloading whitenoise-6.3.0-py3-none-any.whl (19 kB)
Collecting waitress>=1.4.4
Downloading waitress-2.1.2-py3-none-any.whl (57 kB)
---------------------------------------- 57.7/57.7 kB ? eta 0:00:00
Collecting psutil>=5.8.0
Downloading psutil-5.9.4-cp36-abi3-win_amd64.whl (252 kB)
---------------------------------------- 252.5/252.5 kB 15.1 MB/s eta 0:00:00
Collecting shelljob>=0.6.2
Downloading shelljob-0.6.3-py3-none-any.whl (9.9 kB)
Collecting asn1crypto>=1.4.0
Downloading asn1crypto-1.5.1-py2.py3-none-any.whl (105 kB)
---------------------------------------- 105.0/105.0 kB ? eta 0:00:00
Collecting oscrypto>=1.2.1
Downloading oscrypto-1.3.0-py2.py3-none-any.whl (194 kB)
---------------------------------------- 194.6/194.6 kB 11.5 MB/s eta 0:00:00
Collecting distro>=1.5.0
Downloading distro-1.8.0-py3-none-any.whl (20 kB)
Collecting IP2Location==8.9.0
Downloading IP2Location-8.9.0-py3-none-any.whl (16 kB)
Collecting lief>=0.12.1
Downloading lief-0.12.3-cp310-cp310-win_amd64.whl (4.9 MB)
---------------------------------------- 4.9/4.9 MB 12.9 MB/s eta 0:00:00
Collecting http-tools>=2.1.0
Downloading http-tools-2.1.1.tar.gz (550 kB)
---------------------------------------- 550.3/550.3 kB 17.4 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting libsast>=1.5.1
Downloading libsast-1.5.2.tar.gz (36 kB)
Preparing metadata (setup.py) ... done
Collecting pdfkit>=0.6.1
Downloading pdfkit-1.0.0-py3-none-any.whl (12 kB)
Collecting google-play-scraper>=0.1.2
Downloading google_play_scraper-1.2.3-py3-none-any.whl (28 kB)
Collecting androguard==3.4.0a1
Downloading androguard-3.4.0a1-py3-none-any.whl (918 kB)
---------------------------------------- 918.1/918.1 kB 14.6 MB/s eta 0:00:00
Collecting apkid==2.1.4
Downloading apkid-2.1.4-py2.py3-none-any.whl (116 kB)
---------------------------------------- 116.6/116.6 kB ? eta 0:00:00
Collecting quark-engine==22.10.1
Downloading quark_engine-22.10.1-py3-none-any.whl (97 kB)
---------------------------------------- 97.6/97.6 kB ? eta 0:00:00
Collecting frida==15.2.2
Downloading frida-15.2.2.tar.gz (11 kB)
Preparing metadata (setup.py) ... done
Collecting tldextract==3.4.0
Downloading tldextract-3.4.0-py3-none-any.whl (93 kB)
---------------------------------------- 93.9/93.9 kB 5.2 MB/s eta 0:00:00
Collecting openstep-parser==1.5.4
Downloading openstep_parser-1.5.4-py3-none-any.whl (4.5 kB)
Collecting svgutils==0.3.4
Downloading svgutils-0.3.4-py3-none-any.whl (10 kB)
Collecting ruamel.yaml==0.16.13
Downloading ruamel.yaml-0.16.13-py2.py3-none-any.whl (111 kB)
---------------------------------------- 111.9/111.9 kB ? eta 0:00:00
Collecting click==8.0.1
Downloading click-8.0.1-py3-none-any.whl (97 kB)
---------------------------------------- 97.4/97.4 kB ? eta 0:00:00
Collecting decorator==4.4.2
Downloading decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Collecting asgiref<4,>=3.5.2
Downloading asgiref-3.6.0-py3-none-any.whl (23 kB)
Collecting tzdata; sys_platform == "win32"
Downloading tzdata-2022.7-py2.py3-none-any.whl (340 kB)
---------------------------------------- 340.1/340.1 kB 10.6 MB/s eta 0:00:00
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.4.3-py3-none-any.whl (42 kB)
---------------------------------------- 42.8/42.8 kB ? eta 0:00:00
Collecting pyasn1>=0.1.3
Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
---------------------------------------- 77.1/77.1 kB ? eta 0:00:00
Collecting urllib3<1.27,>=1.21.1
Downloading urllib3-1.26.14-py2.py3-none-any.whl (140 kB)
---------------------------------------- 140.6/140.6 kB ? eta 0:00:00
Collecting charset-normalizer<4,>=2
Downloading charset_normalizer-3.0.1-cp310-cp310-win_amd64.whl (96 kB)
---------------------------------------- 96.5/96.5 kB 5.7 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
---------------------------------------- 155.3/155.3 kB 9.7 MB/s eta 0:00:00
Collecting idna<4,>=2.5
Downloading idna-3.4-py3-none-any.whl (61 kB)
---------------------------------------- 61.5/61.5 kB ? eta 0:00:00
Collecting beautifulsoup4
Downloading beautifulsoup4-4.11.2-py3-none-any.whl (129 kB)
---------------------------------------- 129.4/129.4 kB ? eta 0:00:00
Collecting colorama; sys_platform == "win32"
Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting altgraph>=0.17
Downloading altgraph-0.17.3-py2.py3-none-any.whl (21 kB)
Collecting mitmproxy==6.0.2
Downloading mitmproxy-6.0.2-py3-none-any.whl (1.1 MB)
---------------------------------------- 1.1/1.1 MB 14.3 MB/s eta 0:00:00
Collecting markupsafe==2.0.1
Downloading MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl (15 kB)
Collecting pyyaml>=6.0
Downloading PyYAML-6.0-cp310-cp310-win_amd64.whl (151 kB)
---------------------------------------- 151.7/151.7 kB 8.8 MB/s eta 0:00:00
Collecting networkx>=2.2
Downloading networkx-3.0-py3-none-any.whl (2.0 MB)
---------------------------------------- 2.0/2.0 MB 13.0 MB/s eta 0:00:00
Collecting matplotlib>=3.0.2
Downloading matplotlib-3.7.0-cp310-cp310-win_amd64.whl (7.6 MB)
---------------------------------------- 7.6/7.6 MB 12.5 MB/s eta 0:00:00
Collecting pygments>=2.3.1
Downloading Pygments-2.14.0-py3-none-any.whl (1.1 MB)
---------------------------------------- 1.1/1.1 MB 11.8 MB/s eta 0:00:00
Collecting pydot>=1.4.1
Downloading pydot-1.4.2-py2.py3-none-any.whl (21 kB)
Collecting ipython>=5.0.0
Downloading ipython-8.10.0-py3-none-any.whl (784 kB)
---------------------------------------- 784.3/784.3 kB 12.5 MB/s eta 0:00:00
Collecting yara-python-dex>=1.0.1
Downloading yara_python_dex-1.0.4-cp310-cp310-win_amd64.whl (130 kB)
---------------------------------------- 130.2/130.2 kB ? eta 0:00:00
Collecting kaleido
Downloading kaleido-0.2.1-py2.py3-none-win_amd64.whl (65.9 MB)
---------------------------------------- 65.9/65.9 MB 12.6 MB/s eta 0:00:00
Collecting prettytable>=1.0.0
Downloading prettytable-3.6.0-py3-none-any.whl (27 kB)
Collecting tqdm
Downloading tqdm-4.64.1-py2.py3-none-any.whl (78 kB)
---------------------------------------- 78.5/78.5 kB ? eta 0:00:00
Collecting plotly
Downloading plotly-5.13.0-py2.py3-none-any.whl (15.2 MB)
---------------------------------------- 15.2/15.2 MB 12.8 MB/s eta 0:00:00
Collecting prompt-toolkit==3.0.19
Downloading prompt_toolkit-3.0.19-py3-none-any.whl (368 kB)
---------------------------------------- 368.4/368.4 kB 23.9 MB/s eta 0:00:00
Collecting pandas
Downloading pandas-1.5.3-cp310-cp310-win_amd64.whl (10.4 MB)
---------------------------------------- 10.4/10.4 MB 12.6 MB/s eta 0:00:00
Collecting rzpipe
Downloading rzpipe-0.4.0-py3-none-any.whl (11 kB)
Collecting graphviz
Downloading graphviz-0.20.1-py3-none-any.whl (47 kB)
---------------------------------------- 47.0/47.0 kB ? eta 0:00:00
Requirement already satisfied: setuptools in c:\users\das\desktop\k\pentesting android\mobile-security-framework-mobsf\venv\lib\site-packages (from frida==15.2.2->-r requirements.txt (line 26)) (58.1.0)
Collecting requests-file>=1.4
Downloading requests_file-1.5.1-py2.py3-none-any.whl (3.7 kB)
Collecting filelock>=3.0.8
Downloading filelock-3.9.0-py3-none-any.whl (9.7 kB)
Collecting soupsieve>1.2
Downloading soupsieve-2.4-py3-none-any.whl (37 kB)
Collecting tornado<7,>=4.3
Downloading tornado-6.2-cp37-abi3-win_amd64.whl (425 kB)
---------------------------------------- 425.3/425.3 kB 13.4 MB/s eta 0:00:00
Collecting pyparsing<2.5,>=2.4.2
Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
---------------------------------------- 67.8/67.8 kB ? eta 0:00:00
Collecting passlib<1.8,>=1.6.5
Downloading passlib-1.7.4-py2.py3-none-any.whl (525 kB)
---------------------------------------- 525.6/525.6 kB 16.6 MB/s eta 0:00:00
Collecting pydivert<2.2,>=2.0.3; sys_platform == "win32"
Downloading pydivert-2.1.0-py2.py3-none-any.whl (104 kB)
---------------------------------------- 104.7/104.7 kB ? eta 0:00:00
Collecting protobuf<3.15,>=3.14
Downloading protobuf-3.14.0-py2.py3-none-any.whl (173 kB)
---------------------------------------- 173.5/173.5 kB 10.2 MB/s eta 0:00:00
Collecting sortedcontainers<2.4,>=2.3
Downloading sortedcontainers-2.3.0-py2.py3-none-any.whl (29 kB)
Collecting zstandard<0.15,>=0.11
Downloading zstandard-0.14.1.tar.gz (676 kB)
---------------------------------------- 676.8/676.8 kB 14.2 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
Traceback (most recent call last):
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\build_meta.py", line 484, in run_setup
super(_BuildMetaLegacyBackend,
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 63, in <module>
File "C:\Users\DAS\AppData\Local\Temp\pip-install-suw_x1ii\zstandard\setup_zstd.py", line 164, in get_c_extension
compiler.initialize()
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 253, in initialize
vc_env = _get_vc_env(plat_spec)
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\msvc.py", line 210, in msvc14_get_vc_env
return _msvc14_get_vc_env(plat_spec)
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\msvc.py", line 164, in _msvc14_get_vc_env
raise distutils.errors.DistutilsPlatformError(
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
Traceback (most recent call last):
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\venv\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\build_meta.py", line 484, in run_setup
super(_BuildMetaLegacyBackend,
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 63, in <module>
File "C:\Users\DAS\AppData\Local\Temp\pip-install-suw_x1ii\zstandard\setup_zstd.py", line 164, in get_c_extension
compiler.initialize()
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 253, in initialize
vc_env = _get_vc_env(plat_spec)
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\msvc.py", line 210, in msvc14_get_vc_env
return _msvc14_get_vc_env(plat_spec)
File "C:\Users\DAS\AppData\Local\Temp\pip-build-env-dh4tf_vd\overlay\Lib\site-packages\setuptools\msvc.py", line 164, in _msvc14_get_vc_env
raise distutils.errors.DistutilsPlatformError(
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
[INSTALL] Clean Up
=======================MobSF Clean Script for Windows=======================
Running this script will delete the Scan database, all files uploaded and generated.
C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\scripts
Deleting all uploads
Deleting all downloads
Deleting Static Analyzer migrations
Deleting Dynamic Analyzer migrations
Deleting MobSF migrations
Deleting temp and log files
Deleting Scan database
Deleting Secret file
Deleting Previous setup files
Deleting MobSF data directory: "C:\Users\DAS\.MobSF"
Done
[INSTALL] Migrating Database
Traceback (most recent call last):
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\manage.py", line 12, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
Traceback (most recent call last):
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\manage.py", line 12, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
Traceback (most recent call last):
File "C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF\manage.py", line 12, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
Download and Install wkhtmltopdf for PDF Report Generation - https://wkhtmltopdf.org/downloads.html
[INSTALL] Installation Complete
[ERROR] Installation Failed!
Please ensure that all the requirements mentioned in documentation are installed before you run setup script.
Scroll up to see any installation errors.
The 'decorator==4.4.2' distribution was not found and is required by the application
C:\Users\DAS\Desktop\K\Pentesting Android\Mobile-Security-Framework-MobSF>
..........................................................................................................................................................................................................................................................................................................................................................................................................................

Dumpsys meminfo: kB or KB?

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.

How to resolve the usage of the Gfx dev memory

I am using adb shell dumpsys meminfo to get informations about the current memory usage of my app.
The Gfx dev memory increases frequently and seems to cause memory leaks.
Is there an adb command or and Android Studio function to get more informations about the Gfx dev memory and where it is used/referenced?
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 17380 17324 0 0 36864 19380 17483
Dalvik Heap 30366 29796 0 0 50519 48334 2185
Dalvik Other 672 672 0 0
Stack 220 220 0 0
Gfx dev 4704 4704 0 0
Other dev 5 0 4 0
.so mmap 2109 356 872 0
.jar mmap 1 0 0 0
.apk mmap 707 0 420 0
.ttf mmap 35 0 4 0
.dex mmap 7442 0 7400 0
.oat mmap 2712 0 948 0
.art mmap 1458 948 72 0
Other mmap 42 4 0 0
EGL mtrack 13888 13888 0 0
GL mtrack 8924 8924 0 0
Unknown 172 172 0 0
TOTAL 90837 77008 9720 0 87383 67714 19668
Additional Info:
Gfx dev is not available for Kitkat devices and below.
You can use below command to get more info on Gfx;
adb shell dumpsys gfxinfo

Memory Leak LibGDX ANdroid

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.

Using dd to change a hex value in Android script

What I am doing is trying to build a script that can be flashed in a custom android recovery like TWRP or ClockWorkMod.
The beginning: So using this command at a ADB shell prompt will modify the partition in which the locked or unlocked flag lives for the bootloader on many HTC devices-
echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796
I am trying to be able to do the same thing from recovery (Aroma script, but shouldn't matter)
The issue is that while CWM recovery can use these 2 simple lines to complete it:
echo -ne "\000\000\000\000" > /tmp/data_new
dd if=/tmp/data_new of=/dev/block/mmcblk0p3 bs=1 seek=33796 conv=notrunc
TWRP environment cannot. The issue seems to be with the quotes and/or the backslashes in the echo.
To get around this I have tried to package a file called data_new with the output of the echo (which is just 4 nul bytes) and then use the DD command, but it doesn't read the data_new correctly because I get 0+0 records in and 0+0 records out. I have also tried writing a shell script to execute the commands, but same issue in TWRP.
To add a layer of complexity the commands in the aroma script are quoted like this:
run_program("/sbin/busybox", "dd", "if=/tmp/data_new", "of=/dev/block/mmcblk0p3" etc
I have tried many combinations of single and double quotes and leading backticks but still fails.
Bottom line - Is there a different way of expressing 4 zeroed out hex values?
The reverse is not a problem because it's echo to Lock is this: (no backticks and quotes on HTCU don't come into play, since echo output is the same with or without)
echo -ne "HTCU" | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796
The issue is in getting a DD command to change the HTCU values to 4 zeroes without using backticks in the echo.
Can anyone help?
PS - I think that this could be done by pulling the partition with DD to /tmp and then find the HTCU string (48 54 43 55) and replace with 00 00 00 00, but the partition is large with only a small amount of data actually in it so the process would take a while and the script would be more complicated than I think I could write, as yes I am a noob to coding.
Thanks
EDIT: I tried using /dev/null as that seems like a good idea and a way to avoid echo altogether. However that fails as well. Same result as using a preloaded 4 nul byte file. I know it is not the recovery as the /dev/null method produced the same failure in a ADB shell.
0+0 records in
0+0 records out
0 bytes copied
Here is the full string of code:
run_program("/sbin/busybox", "dd", "if=/dev/null", "of=/dev/block/mmcblk0p3", "bs=1", "count=4", "seek=33796", "conv=notrunc")
After dd, what might be the best alternate way to do a quick hex edit?
This is my requirement:
writting into parttion mmcblk0p3 at offset 0x8404. HTCU for unlocked, HTCL for relocked or 0x00000000 for locked
Thanks again
Could you not read directly from /dev/null reading 4 bytes; I believe the syntax is:
dd if=/dev/null of=/dev/block/mmcblk0p3 bs=1 count=4 seek=33796 conv=notrunc
Please double check the above code, I've not used dd in a while.
Update
After playing around with dd I managed to get it to write 4 null bytes to a position I specified within a file:
Firstly create the example file:
$ dd if=/dev/urandom of=randomfile bs=64 count=1
1+0 records in
1+0 records out
64 bytes (64 B) copied, 4.5401e-05 s, 1.4 MB/s
$ od -b randomfile
0000000 105 342 131 116 213 371 352 344 217 236 320 106 010 154 074 375
0000020 360 215 014 203 030 357 144 053 302 265 012 310 217 362 236 303
0000040 156 033 266 035 303 061 262 055 253 102 222 037 372 105 230 321
0000060 117 277 322 277 166 174 316 176 010 202 302 151 120 045 120 334
0000100
Then zeroing 4 bytes, skipping the first two bytes:
$ dd if=/dev/zero of=randomfile seek=2 bs=1 count=4 conv=notrunc
4+0 records in
4+0 records out
4 bytes (4 B) copied, 4.4779e-05 s, 89.3 kB/s
$ od -b randomfile
0000000 105 342 000 000 000 000 352 344 217 236 320 106 010 154 074 375
0000020 360 215 014 203 030 357 144 053 302 265 012 310 217 362 236 303
0000040 156 033 266 035 303 061 262 055 253 102 222 037 372 105 230 321
0000060 117 277 322 277 166 174 316 176 010 202 302 151 120 045 120 334
0000100
This should extend to your larger file.
dd if=/dev/null of=/dev/block/mmcblk2p3 bs=1 count=4 seek=33796 conv=notrunc
This above Ans worked for me... Thanks for the Ans.
dd if=/dev/null of=/dev/block/mmcblk2p3 bs=1 count=4 seek=33796
without conv=notrunc argument it used to give
dd: ftruncate: Invalid argument error.

Categories

Resources