Should the Dalvik cache on Android phones be cleared periodically?

In summary, the phone was getting too slow to work with, so I rooted it and removed pre-installed bloatware. I also back up my data regularly.
  • #1
Wrichik Basu
Science Advisor
Insights Author
Gold Member
2,116
2,691
Finally, after a lot of hesitation, I rooted my phone (Samsung Galaxy On7, Android 6.0.1) using Magisk systemless root. The main aim was to remove pre-installed useless software (often termed "bloatware").

I didn't want to flash Magisk using TWRP, because installing TWRP would remove the stock recovery, and I would never get it back. I tried rooting using the Magisk installer itself, but it failed. So I had to unwillingly install TWRP first (thereby losing the stock recovery). I tried doing that using ADB (actually fastboot), but it couldn't recognise the device in bootloader mode. So I downloaded Odin and flashed TWRP. Then I flashed the Magisk zip file.

After the flashing was over, I also cleared the Dalvik cache, not knowing that this was not necessary. When I rebooted the phone, it took a long time to boot. It was showing, "Optimizing apps". I thought I had cracked the phone up and it was a boot loop. But later I found that everything was fine. In addition, clearing of the Dalvik cache actually freed up the internal memory by about 1GB.

I read online that Dalvik cache is actually the optimized dex files that the dex compiler builds to ensure the smooth running of applications. Now, the last official update to this phone was back in April 2018. Is it possible that the phone retained the cache of all apps since then, including the ones I had uninstalled? It seems so, otherwise how could I recover about 1GB of memory simply by clearing the Dalvik cache?

If I am correct that clearing the Dalvik cache freed up space, does it make sense to clear the Dalvik cache periodically, say annually, so as to prevent misuse of the "precious" internal memory?
 
Computer science news on Phys.org
  • #2
Wow! What a lot of work and trouble. I know that bloatware is annoying, but was it worth that much to get rid of it?
 
  • #3
anorlunda said:
Wow! What a lot of work and trouble. I know that bloatware is annoying, but was it worth that much to get rid of it?
Actually, my phone was getting too slow to work with. I never had any games installed (except maybe when the phone was first bought, but that is a long time back). I specifically installed the apps which could be moved to SD card. Even then, every morning, I would see more and more of internal storage being used up. This became irritating. If I took the phone to a service centre, they would either do a factory reset or ask me to change the motherboard. The second one is quite costly.

I read online that if you root the phone, then you can remove these system apps easily. Although your reserved system space is still not available for user app installations, the phone still becomes a bit faster, at least people on StackOverflow commented so. (You can actually use the freed-up system reserved space if you want, using the Magisk module "App Systemizer". It converts user-installed apps to system apps, and those will stay even if you unroot your device). Basically, this was the motivation. In addition, I was always interested in stuff like these, so it was not much trouble, except that I was scared that I might brick the phone. Also, XDA Developers have published extensive guides to root a phone, and they are very helpful for beginners like me.
 
  • Like
Likes anorlunda
  • #4
Update: The phone suddenly switched itself off, and is now in a bootloop.:cry::headbang:
 
  • #5
Update #2: Amidst the tension of losing the phone, it came to my mind that if I can somehow get the stock ROM and flash it, the phone will come back. So I started searching the net frantically, and finally came across the stock ROM. Downloaded it (a 1GB file), flashed it with Odin (the phone was able to enter recovery and download mode).

And finally, I have my phone back! Phew!
 
  • #6
General rule with computers:
Make a backup FIRST!
 
  • #7
Tom.G said:
General rule with computers:
Make a backup FIRST!
I store all my data in SD Card, so I didn't lose any personal data. What I lost was a couple of screenshots in the phone memory. My contacts are in Google account, so no fear losing them.

What I should have backed up was the stock ROM. The version of stock ROM that I found online was an old one, and I had to download all the OTA updates. As soon as all the updates were downloaded, I installed TWRP and backed up the system and app data. It is a ~5GB file, and I shall keep it safely for the future.
 
  • Like
Likes Tom.G

1. What is Dalvik cache on Android phones?

The Dalvik cache is a temporary storage area on Android phones that stores pre-optimized code and resources for faster app launching and smoother performance. It is created by the Android operating system for each app installed on the device.

2. Why should the Dalvik cache be cleared periodically?

Clearing the Dalvik cache can help improve the overall performance of an Android phone. As the cache grows over time, it can cause apps to launch slower and take up more storage space. Clearing it periodically can free up space and force the system to create a new cache, which can potentially improve performance.

3. How often should the Dalvik cache be cleared?

The frequency of clearing the Dalvik cache depends on the usage and storage space of the device. It is recommended to clear it every few months or when the device starts to experience slow performance. However, some users prefer to clear it more frequently, such as once a month.

4. Will clearing the Dalvik cache delete any important data?

No, clearing the Dalvik cache will not delete any important data or personal information. It will only remove temporary files and pre-optimized code for apps, which will be recreated by the system when needed. However, it is always recommended to back up important data before clearing the cache, just in case.

5. How do I clear the Dalvik cache on my Android phone?

The steps to clear the Dalvik cache may vary slightly depending on the device, but generally, it can be done by going to Settings > Storage > Cached data, and then selecting "Clear cache". Alternatively, some devices may have a "Clear cache" option in the recovery mode. It is recommended to consult the device's manual or do a quick online search for specific instructions for your device.

Similar threads

  • Computing and Technology
Replies
13
Views
5K
  • Computing and Technology
Replies
16
Views
6K
  • Computing and Technology
Replies
5
Views
4K
  • Computing and Technology
Replies
1
Views
2K
  • Computing and Technology
Replies
9
Views
3K
  • Computing and Technology
Replies
3
Views
2K
  • Computing and Technology
Replies
1
Views
2K
Back
Top