My question is more like the best route taken for the purpose for saving memory and more efficiency.
So lets start off, I have a zip file which I use the class “ZipInputStream” to search for a specific file(Image), and after obtaining the location of the image I process it into an image and show it off to a user. Now I want to store this image so it doesn’t go to the entire process of Streaming out files within a zip file.
I am currently doing this process:
Process 1:
“Saving the inputstream into memory into a hashmap and after I have reach a certain limit in memory I delete it.”
Process 2:
Then I was thinking it might be more efficient if I just save out the location used within the zipInputStream and just go back to that location and just zip within the zip file through the proper location. This way I have the ability to obtain the image without straining the memory. I haven’t tested out this theory though.
Summary:
Process 1 has it’s weaknesses such as users just rushing through the functions and may eventually crash. Process 2 may work out more memory wise and load slightly longer.
Question:
“So which route should I take? 1 , 2, or something in haven’t put out in this question”.
What I would do is store the images themselves in a LruCache. This is a cache that gets cleared when an image isn’t used in a while. When the image gets removed, simply repeat the process of loading the image. This is safe and fast.