How do I free up the memory used by Shinobi?


#1

Unfortunately I have a few out of memory terminations in my app. I have seen that the apps used memory is increased considerably after displaying the first chart and it doesn’t get freed when I close it. Do you have any info on how to free up the memory used by Shinobi?

It doesn’t seem to increase when showing and hiding the chart views, but there is a big difference between before and after displaying the first chart, about 23 MB


#2

We’re aware of a memory issue that was raised in this post: does it look like this is the issue here?

The reason this issue has not yet been prioritised for fixing is that it’s not a problem that builds up, so it seems unlikely to be the cause of an out of memory termination.

Could you tell us a bit more about your app to help us work out what the issue might be?

  • Which version of shinobicharts are you using?
  • How are you adding/removing the charts?
  • How many charts do you have in memory at any one time?
  • How many data points are you displaying at once?
  • Have you seen the out of memory terminations yourself, or is it something that only happens in the wild?

#3
  • 2.9.8 and advanced chartingkit 0.10.0

  • I have a UIView adds the chart as a subview

  • Only one chart at a time. When changing it I remove the chart from its superview first and nil the reference. Same goes when view dissapears

  • The number of datapoints varies and depends on the user, but around 1000

  • According to crashlytics the out of memory termination rate is high around 80%. I have seen many crashes myself especially when going back and forth between my app and other apps.

Just noticed that the 23MB number was on the simulator, but it is considerably less on the actual devices. Still, I do see a memory bump when shinobi has been used. The theme used in the chart seems to be leaking. Can you clear it?


#4

Hi siper,

First of all, the charts use OpenGL, and according to Apple’s OpenGL docs the simulator should not be used for profiling of OpenGL apps, so I think the 23MB is a bit of a red herring and probably caused by the OpenGL simulation.

If you use the default theme for your charts then it uses a static theme, to avoid recreating it for multiple charts. I’ve logged an issue for us to investigate whether this is the best approach. In the meantime you could create your own theme and pass it to the chart on initialization, which will avoid creating the default theme. However, my tests in Instruments suggest the memory saved is only in the region of 30kB, so not the sorts of numbers that would cause an out of memory exception.

Using a single chart at a time and around 1000 data points should not be causing any memory issues. Have you profiled your app using Instruments to determine what’s causing such high memory usage? If it is caused by shinobicharts then please could you send us your profile so we can take a look?

Thanks,

Alison


#5

Yes, I did the initial tests on the simulator… so the 23 MB number is innacurate. But still there is a bump in memory usage as soon as I render data on the chart.

I noticed the leak on the theme, but 30kb is not the issue, so it must be something else. I’ll get back to you with more info.