I am using SDWebImage library for fetching and caching images in a table view. However the app crashes due to low memory when i use the option SDWebImageProgressiveDownload.Also the library seems to be slow in downloading images. I dont think its caching them coz every time i request to fetch the same amount of time is taken to download. Has anyone encountered the same problem? Is there a solution for this?
Related
I’ve got a simple question
I made an application similar to instagram, the only difference is that it has more stories&posts because there’s no following system.
I do cache the images and videos, but should I delete the caches with a timer?
It is lots of videos and images.
Or is it enough to cache and when terminating the app clear the caches
If you're using standard caching mechanisms like NSCache, the OS will automatically clean it when it needs more memory for other applications. You don't need to worry about cleaning cache manually, unless you need some app specific behaviour.
I use alamofireimage for loading images async and I use AutoPurgingImageCache for caching the loaded images (url request). I have a pull-to-refresh feature in my app and after I do that even if the app content remains the same I see that the app size is increasing and alamofire does not fetch the images from cache and instead it loads them from new requests. Profiling the app reveals that a memory issue exists in alamofire. I have attached the screen shot. I would appreciate if someone has some insight into this.
What cache size did you specify? It's possible that you're experiencing cache misses because the number of distinct images you request per-refresh is more than large enough to fill up the entire cache.
It's also possible that the cache key, i.e. image URL, is changing between refreshes, which could prevent your caching mechanism from correctly looking up cached images.
It's certainly possible there's a problem with AlamoFire, but you should probably start by examining your caching setup for problems like the above.
I want to use NSURLSession to upload photos to cloud server(like OneDrive) and I hope the app can do works in background.
But NSURLSession just support "fromFile" not "fromData" in background mode, and I don't know how to get the NSURL of photos, so I write the photo's data into a file...
I think this is not a good way.
From the comments above, it seems like you'll be uploading several photos at a time and for that a "fromData" approach does not seem like a good idea.
Firstly, high resolution photos have several megabytes in size. If your loading a 5mb photo into memory, using NSData, you're probably fine. But loading 10 photos would then mean you'd need 50mb of memory to hold them all.
Secondly, uploading large chunks of data, such as photos, is also a computationally intensive task. You should most definitely not try to upload them all at the same time. This means you're going to have to build an upload queue that only starts uploading the next photo once the last one has finished. What happens then if internet connectivity is lost midway through the process? And what happens if the user closes the app all of the sudden?
Thus, I'd suggest you grab all the images' data and write them to a temporary folder somewhere. Then you start the upload process, which would find a file on the temporary folder, upload it, delete it once the upload finishes successfully and start over with the next file.
This way you're minimising your app's memory footprint, making it more resilient in the face of the many adversities an app may face (no internet connection, being prematurely closed by the user and so on) and also abiding by the APIs that are provided to you.
We're using Parse in our iOS app and we've discovered that our app is using an enormous amount of space -around 2.3GB in some devices- in storage. After downloading app data to my Mac, I've realized almost all of that data is the cached images in a folder called PFFileStaging, it contains highest resolution PNGs of all the PFFiles that the user has viewed in our app, ever. How can we disable this behavior, at least limit it? Is that the intended behavior? I heavily doubt using GBs of space is the intended behavior. Is this a bug?
Unfortunately this is not cache related (as per Parse's engineers: "this is used to ensure that no concurrent modification happens to the file after you request uploading").
They're planning to implement automatic trimming of PFFileStaging folder on every app start (as per road plan this should appear in next version 1.8.2).
See the the whole thread on GitHub.
Can someone help me out, i am facing a issues since many days.
My Application is lagging(Users feel like the app is almost struck) at the launch screen while handling image data from server and saving it in the local SQLite Database. It would be great if someone could provide me with some solution for the same.
Thank You.
It is hard to figure out the cause without any code but if the user is complaining that the application is lagging, there is a good chance that you are doing work on the main thread and locking up the UI. You should do as much of this work as you can on a background thread as to not freeze the User Interface. If your app is useless unless this data is ready, you should design a flow where the application lets the user know that it is doing some work instead of just freezing the application UI.