Android Question What physical memory for dirinternal / cache ?

robotop

Member
Licensed User
Longtime User
Hello all, I have an evolving application that stores very frequently some temporary files.
I know that flash memories have a limited number of writes, so I don't want to use such memory for very frequent data storing. I read from first posts of B4A that file.DirInternal and file.DirInternalCache both uses "internal memory", but it's not clear to me if we are speaking about ram (like a ramdisk) or flash. Any help will be highly appreciated, thanks.
 

Linostar

Member
Licensed User
Longtime User
Hello all, I have an evolving application that stores very frequently some temporary files.
I know that flash memories have a limited number of writes, so I don't want to use such memory for very frequent data storing. I read from first posts of B4A that file.DirInternal and file.DirInternalCache both uses "internal memory", but it's not clear to me if we are speaking about ram (like a ramdisk) or flash. Any help will be highly appreciated, thanks.

The internal memory is where the Android system is installed. Depending on the device, the internal memory is either a ROM or an internal SD card, and both are, technically speaking, EEPROM or Flash memory. But don't let bother you, flash memories have life expectencies much higher than what you're thinking.
 
Upvote 0

robotop

Member
Licensed User
Longtime User
Hi, thank you for answering to my question. In my opinion, "internal memory" is Flash (Nand Flash, more often than Nor Flash, actually) and Ram. I know Android lies on a linux kernel, so (as any other linux system) can have a ramdisk. My question was intended to discover if there is any file.dir that points to a real ramdisk. The expected life of a flash memory isn't so high as you think. In practice, there are algorithms that, in the background, store data on the whole memory space, just to avoid to re-write the same cells, with the target of extending its life, but for proper nature, a Flash memory HAS a limited number of writes on same cell. The cell becames "old" and every write operation needs for additional time (erase / re-write) and when too old, the write fails. With the cited "data spreading" algorithm, the memory life is extended 'cause all the cells are used in a distributed mode. So, the larger free memory you have, the longer life can you expect. If you have low free memory, the algorithm can distribute the data only on such space, so it becames less efficient. In any case, if you have really quickly updating data, it's better to use the Ram, that is made just for this purpose. Anyway, I change my question in: "is there a file.dir that points to a ramdisk ?" Thanks.
 
Upvote 0

Linostar

Member
Licensed User
Longtime User
Aside from the ramdisk of the kernel, there appears to be none.

You may want to consider saving your temporary files outside your device, through the internet for example (into a computer, a server or even a cloud)?
 
Upvote 0

robotop

Member
Licensed User
Longtime User
Hi, not realistic to save data on a cloud or server or on external device. I mentioned that the data update is VERY frequent and anyway the application must work even if the phone is not connected with any net or external device. May be the solution can be to direct the output stream to a reserved ram space (a string, or a byte array) instead of a file. Actually I don't know if it's possible under B4A; I will search on the forum... If someone has a shortcut for this, it's welcome :)
 
Upvote 0

robotop

Member
Licensed User
Longtime User
Thank you, Erel. As usual, you know the solution... :)
 
Upvote 0
Top