views:

163

answers:

0

Hello all,

I'm currently facing some performance issues, when using several custom layers as sublayers inside my view.

After creating my new layer programmatically, I add it as sublayer, like:

[self.view.layer addSublayer:myNewSublayer]; 

This works just fine. However, when doing this over and over my app starts to slow down more and more. I'm pretty sure this happens, because I'm constantly adding a new sublayer to my view. So, in order to solve this problem, I tried to remove everything from self.view.layer before adding new sublayers, like:

[self.view.layer setContents:nil];

Unfortunately this didn't solve my problem.

My new sublayers are correctly released after being added as sublayer. I checked this in instruments and there are definitely no memory leaks. However, I do see that memory is incrementing every time I'm adding new sublayers (which is nothing that would surprise me).

I think I need to find a different way to remove all sublayers from my view's layer.

Any help appreciated. Thanks in advance.