So ,if i have a List<Bitmap> myBitmaps where i should store lot of Bitmaps token from a DataBase ,and it might a Out of Memory Exception ,how can i avoid that .
Should i store a bunch of Images at Hard Drive ,than load another Bunch after first bunch Processing etc.
Another case is if i load a Base64 and encode to String and String to Base64 against large amount of data how can i achieve it without causing Out of Memory Exception ,and how can i predict if there is going to be a Out of Memory Exception in both cases .
PS : If someone offers a solution please could it explain if it’s slows Performance and why .
From the sound of it, it seems like the
Bitmapsare large and it will be impractical to store them all in memory. If you are doing bulk operations on it then swapping to disk will certainly cause performance degradation but given that in real world you are working with hardware limits there are no options.You might be able to cache certain metadata about the bitmaps in memory to speedup operations. Another option is to cache entire bitmaps in memory and go to the disk when data is not available in core memory.
Exactly which ones you cache will again depend on usage pattern. Consider using
WeakReferenceas well.Base64 conversion for large data can be trivially converted to an online algorithm, converting small amount of data at a time.