flyingchris
flyingchris

Reputation: 316

Is there a way to store ~1GB max on device memory (RAM)?

I'm currently working on a dashcam app and I was trying to store images over a specific timeframe and either delete them when they are too old or create a video from them.

However I am constantly running into a storage problem. My plan was to cache the bitmaps in the device memory, because worstcase would be 60 images per second and compressing bitmaps takes some time, so I wanted to do that only if I have to. Like when generating the video out of single images.

I wanted to preserve the lifetime of the NAND-Flash storage. So my plan was to save a list of bitmaps in system memory and only collect, compress and save them to storage when I want to generate the video.

So tl;dr: Is there a way to save ~1GB of temporary data on android except writing and deleting it to/from storage?

So I already tried some different things:

Well I expected Android to delete the temporary files because thats what written in the documentation. But thats also why I'm asking for help so I'm not sure what to say here other than thanks in advance.

Upvotes: 2

Views: 180

Answers (1)

Léo Germond
Léo Germond

Reputation: 721

I wanted to preserve the lifetime of the NAND-Flash storage. So my plan was to save a list of bitmaps in system memory and only collect, compress and save them to storage when I want to generate the video.

This right here is the heart of your issue: you don't need to do that at all. Modern flash have a large number of erase-cycles (100,000+), on top of that if you add wear-leveling and aggressive caching by the OS, it means you are thinking about a non issue: save large files to filesystem and don't bother reinventing this old complicated and perfectly functioning wheel.

collect, compress and save them to storage when I want to generate the video

I think by directly using the compressed video feed from the camera instead of compressing raw BMPs by yourself, you will be much more efficient. Seriously MPEG compression is better than anything you will come up with and the cost is nil because nowadays embedded cameras have built-in stream encoders that start working as soon as the camera is turned-on.

I would focus more on the specific of the BMP and video I want to generate and analyze / distribute (resolution, GOP-size...) in regard to phones on the market, rather than the specifics of how to compress BMP or how to protect the NAND.

Upvotes: 1

Related Questions