I am writing an Android application which writes data to a file several times a second, the overall file size is around 1MB, after that file gets erased and new file started. Should I be concerned about wearing out the phone's flash memory, causing it to fail? Do you know if Android distributes writes onto different sectors to minimize flash memory degradation, even when the application writes a continuous file? Does the logging system worked in a similar way? In other words if I log a lot (several records per second), will that affect the phone's flash memory resource?
Would not hurt to worry about that, but aside from flash write cycles, I'd rework app logic - 1MB is not that much, so buffering data in memory and flushing it to the file periodically (but less frequently) should speed your app (as I assume your writes are synchronous).
EDIT
Wiki got some figures for consideration:
Write endurance
The write endurance of SLC floating-gate NOR flash is typically equal to or greater than that of NAND flash, while MLC NOR and NAND flash have similar endurance capabilities. Example Endurance cycle ratings listed in datasheets for NAND and NOR flash are provided.
- SLC NAND flash is typically rated at about 100k cycles (Samsung OneNAND KFW4G16Q2M)
- MLC NAND flash used to be rated at about 5k – 10k cycles (Samsung K9G8G08U0M) but is now typically 1k – 3k cycles
- TLC NAND flash is typically rated at about 1k cycles (Samsung 840)
- SLC floating-gate NOR flash has typical endurance rating of 100k to 1M cycles (Numonyx M58BW 100k; Spansion S29CD016J 1,000k) MLC floating-gate NOR flash has typical endurance rating of 100k cycles (Numonyx J3 flash)
It depends on the memory type and file system. NAND flash memories provide higher number of write cycles compared to NOR memories. Also, file systems such as JFFS2 provide a wear leveling algorithm to distribute the data and avoid block damage.
A comparison of NAND and NOR flash techs: https://focus.ti.com/pdfs/omap/diskonchipvsnor.pdf
Storage media's lifetime depends on physical structure and filesystem. In most of Android device we used eMMc or NAND flash to store rootfs/user data. The best combination is eMMC+ext4 then NAND+UBIFS.
UBIFS is better than JFFS2 not only in speed but in lifetime too. similar to ext4 UBIFS have UBI volume and data write-back, Look at this :http://www.linux-mtd.infradead.org/doc/ubifs.html#L_ubifs_mlc
Don't worry about the log files in /var/log, several records per second do not affect NAND flash's lifetime. Different from JFFS2 writes to flash immediately, UBIFS has data write-back. UBIFS is better than JFFS2 in wear leveling.
© 2022 - 2024 — McMap. All rights reserved.