VM tweak is a build.prop modification/hack that lets you free more space on the internal storage of your Android device.
Android has never been kind with low-end devices. With each new release, storage and hardware requirements are getting higher. This is more of an Operating System design drawback: It is well known that Android makes extensive use of the Java programming language in its internals and that almost all third-party Android Apps are written in Java.
Java needs a Virtual Machine (VM) to run. The VM is responsible for interpreting the Java code into hardware-specific bytecode, which is then executed on the device processor. When the workload is big, this procedure might be slow, even on devices with higher specifications.
To face this, Google developed its own VM which incorporated various optimizations for its OS. Android has been using the Dalvik VM up to Android KitKat. It featured Just-In-Time compilation, which saved an app’s bytecode on the device storage (dalvik-cache) when it was executed for the first time. Since Android Lollipop, ART was introduced and officially replaced Dalvik.
ART enables Ahead-Of-Time complication (AOT), which actually compiles Apps into bytecode before they are opened by the user and saves them to cache, in an effort to increase the system responsiveness and speed. All these optimizations though are not designed having budget devices in mind. They usually make use of big amounts of storage space and computational power.
Related guide: Free Up Space on Android Devices with These Handy Tips
Leaving the technical information aside, there is a way of disabling JIT and AOT and having Dalvik/ART interpreting Apps directly at the time they are being executed, without saving any bytecode to the storage. This might actually keep the device processor busier, but most devices can easily handle the extra load. It can be done by editing the build.prop file on the System partition.
- Some manufacturers tend to ship custom Dalvik/ART VM run-time libraries with stock ROMs, where the VM will not take the following configuration parameters into consideration on boot and there will be no difference after applying them. If you are using a custom-built AOSP/CyanogenMod/LineageOS based ROM, most probably this procedure will work on your device.
- Make a full backup of your device before applying these changes. There is a chance you get a boot-loop.
- Root Support. Needed for editing the build.prop file
Now describe the steps described below:
Getting Free Space on Android Internal Storage with a VM Tweak
- Open and edit your build.prop file. I will not get into details on how to do this since it is covered already on Droidviews here.
- Add (or change if they are already available) the following lines in build.prop:
dalvik.vm.dex2oat-filter=interpret-only dalvik.vm.image-dex2oat-filter=interpret-only dalvik.vm.usejit=false
- Save the file
Clean Dalvik-cache/ART-cache. If you have a custom recovery installed, you can do this through the recovery UI. Otherwise, this can be done by opening a terminal app on Android and applying the following commands:
su rm -rf /data/dalvik-cache
Reboot your device. If you see a message while booting informing about optimizing Apps, then most probably your VM does not support these properties.
If this procedure works on your device, you will get some extra free space on Android internal storage. Its amount will depend on the number and size of installed apps.