0

I'm using a big sized label and it takes too much memory. The problem is described in UILabel (CALayer) is using large amounts of virtual memory and in How to suck down iOS memory without even trying.

Is it possible to exchange the backing layer of the UILabel through e.g. CATiledLayer?

What I'm trying to do is to reduce the used memory for the UILabel. Using a clear background color for example doesn't help. Don't know how this is meant exactly:

but then you don’t respond to the drawRect method to draw your view’s contents

Community
  • 1
  • 1
testing
  • 19,681
  • 50
  • 236
  • 417
  • which devices are you programming for? – Larry Pickles Aug 18 '15 at 14:18
  • iOS Devices like iPhone, iPad, iPod touch. – testing Aug 18 '15 at 14:19
  • and what are you trying to accomplish, why is this even propping up as an issue for you? – Larry Pickles Aug 18 '15 at 14:19
  • IOS devices is obvious, WHICH specific devices for IOS, iphone 4? iphone 5, iphone 6, Ipad 2, which ones? – Larry Pickles Aug 18 '15 at 14:19
  • I have a memory problem. See [here](http://stackoverflow.com/questions/32053817/app-ios-crashes-with-terminating-in-response-to-backboardds-termination). All devices which supports iOS 7 and up. That means iPhone 4, iPad 2 and all generations which followed them. – testing Aug 18 '15 at 14:21
  • the first BIG issue where there's going to be very little help that you can find here, sorry about this, is that you are using Xamarin. There's way to tell what may be going on in the background when using a third party programming environment. This is going to be a touch one. I wish I could say that Xamarin is smart enough to know what they are doing, but Apple hasn't passed over any magic keys to them to see inside the black box, so it's impossible to give you a straight answer. – Larry Pickles Aug 18 '15 at 14:24
  • (1) it's basically impossible that can be using "too much memory". (2) I think the blunt way to describe xamarin is "don't use xamarin". these days it is infinitely easier to simply make a native app. as Lacerax has said, the people who make Xamarin would have no hope of fixing the problem, you will have no hope of fixing the problem, and certainly nobody here will have a hope of fixing the problem. – Fattie Aug 18 '15 at 14:28
  • Yeah, I know. If I know the Apple context, most of the time I can figure it out to do the Xamarin way. – testing Aug 18 '15 at 14:30
  • life is incredibly short. don't use xamarin. it's really that simple :/ things like xamarin were made in **ancient history** when it was "hard" to make a native ios app. the situation just couldn't be simpler: it's simply now much easier to make a native-only app. every second you waste with it is a second of your life wasted forever :-) – Fattie Aug 18 '15 at 14:33

1 Answers1

2

You can't back a UILabel with a CATiledLayer, but there's no reason to, either. If you're switching to CATiledLayer (which is probably the correct solution), then you're going to have to manage your own layout anyway. Once you're doing that, UILabel isn't buying you a lot. Just use a UIView and tile it as you suggest.

That said, the question you link discusses creating 500 UILabels. That's a crazy number of labels. You should be using other tools, like CATiledLayer, infinite UIScrollView, UITableView, etc. that allow you to manage a smaller number of reusable views.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • "and don't use xamarin" ;-) actually another princple reason to "not use xamarin" is Rob is not available for questions on it :-) – Fattie Aug 18 '15 at 14:29
  • Well, that should go without saying. I didn't notice that in the linked question. Yeah, Xamarin is going to make everything harder, especially if performance is of *any* concern. It's hard enough to get high performance mobile done close to the metal; doing it through one more abstraction layer that Apple doesn't help you with is a difficult choice. http://robnapier.net/product-or-process – Rob Napier Aug 18 '15 at 14:30
  • It is only one big label, but that is enough to kill the app after some time. So I have to use another mechanism. Thanks for clarification. – testing Aug 18 '15 at 14:35