nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
12k stars 2.58k forks source link

Continuously Rising Memory Usage When Autoscroll Enabled #848

Open snout-o opened 6 years ago

snout-o commented 6 years ago

[Edit: I could be reading Instruments wrong. Upon closer inspection I can see the Persistent Bytes and #Persistent columns level out quite quickly, whereas it is the other columns (Transient, Total Bytes, Total) that continue to climb. These could simply be cumulative columns and not representative of increasing memory usage. I apologise in advance if that is the case but would like to hear from someone who knows for certain.]

I'm using iCarousel with an autoscroll value set to something like -1.0f as shown in the code snippet below. This allows the carousel to rotate on it's own without user interaction.

carousel.type = iCarouselTypeRotary;
carousel.autoscroll=-0.15f; // <--- here is where I set autoscroll 
carousel.scrollEnabled=NO;
carousel.centerItemWhenSelected=NO;
carousel.perspective=-0.0045;

I've been checking memory allocations in Instruments and have noticed that allocations are on a constant upward trajectory when iCarousel is scrolling. It increments the total heap by something like 1MiB every ~1.5 seconds - clearly my app can not sustain that for too long.

instruments2

In the image above, everything above the red line continues to increase in memory allocation.

I've tried using FXImageView instead of UIImageView and removed UIImage imageNamed calls, hoping this would clear up the issue, but to no avail.

What's telling is that if I comment out the autoscroll line in the code and run Instruments again the allocations are almost entirely static, as the image below hopefully illustrates.

instruments2b

Just simply adding back in that line causes this seemingly never-ending memory allocation.

Any thoughts on the cause and how to fix? My app is expected to run continuously for long periods of time and this sort of memory issue will kill it very quickly.

Thanks!