Recently in a File Management page, there are a lot of features, there is a thumbnail download (socket), there is file Download (HTTP).
Say the thumbnail download this piece, my uitableview a cell to load four thumbnails, IPhone5S's screen can load 8 rows. This is probably the way the UI is laid out. (in addition, thumbnails need a single download)
Just started to go to the file management interface, memory consumption of 20 m, as thumbnails continue to download in the presence of rising, I constantly pull up, memory value is rising. Reach a certain value app appears to flash back. It's about 300 m. What causes it?
Look first:
I wrote this: Create an object that has a property of UIImage. Objects are stored inside the array. There are about 800 photos.
When the thumbnail is not downloaded, I'm loading a default image. When the thumbnail is downloaded, I assign the downloaded thumbnail to the UIImage property of the corresponding object.
The cell is reused, so there should be no problem. But memory is constantly rising, and is not moving when the memory does not rise, up and down sliding uitableview, memory is rising.
I've been thinking about cell reuse, how does memory keep rising? The problem is not caused by the cell, but by the UIImage property of the object I said above.
Think about it, thumbnails are constantly downloaded, downloaded thumbnails are assigned to the object's UIImage property, and the object is in the array, it is conceivable that more than 800 thumbnails constantly download memory certainly rose.
So, I removed the object's UIImage property, the downloaded photos through the Egocache cache, load the cell on the UIImage, directly from the cache to take out.
The code is as follows:
[[Egocache Globalcache] setimage:image forkey:[nsstring stringwithformat:@ "Egoimageloader-%lu", (unsigned long) [[ Fmobject.path description] [] withtimeoutinterval:cacheingtime];
Run again and look at this piece of memory:
Sure enough, the problem was solved. It seems to be prudent to add uiimage attributes to the object later!
There are questions you can join Swift Learning Exchange Group:
QQ Group: 303868520
or follow my public number: iOS Development: Iosdevtip
iOS development: UITableView loading multiple photos causes memory to rise