Image caching was an important part of the application that I created and placed in the application store. The application must download the images and cache them both in memory and on the SD card, so that their scope goes beyond a single run.
The general idea was to add images to the Caching Manager, which: a) stores the image in an associative container (HashMap) using a metadata-based key and b) writes the image file to the SDCard,
In low memory conditions, I release the HashMap. However, images can still be retrieved from the SD_Card and cached into memory again.
I was able to do this without recycling and still do not see memory problems. As far as I understand, re-utilization is not needed, but it helps to get an earlier version of the memory used for "bitmap images" due to the fact that the allocation for bitmaps in operations with the Gingerbread preliminary pointer uses Native Memory. those. memory not included in the Dalvik heap. Thus, the garbage collector does not free this memory, but frees it from specific policies.
This is from the Cache_Manager class:
public static synchronized void addImage(Bitmap b, String urlString, boolean bSaveToFile, IMAGE_TYPES eIT, boolean bForce) { String szKey = getKeyFromUrlString(urlString, eIT); if (false == m_hmCachedImages.containsKey(szKey) || bForce) { m_hmCachedImages.put(szKey, b); if (bSaveToFile) { boolean bIsNull = false;
// Here is an example writeImage () from the File_Manager class
public static void writeImage(Bitmap bmp, String szFileName) { checkStorage(); if (false == mExternalStorageWriteable) { Log.e("FileMan", "No Writable External Device Available"); return; } try {
paiego
source share