Home » Android » android – Tag: TextLayoutCache Text: Cache Value deleted

android – Tag: TextLayoutCache Text: Cache Value deleted

Posted by: admin May 14, 2020 Leave a comment

Questions:

While debugging my Android app at certain point I’m seeing a huge amount of entries in the LogCat with the

Tag: TextLayoutCache Text: Cache Value 0x51b9f578 deleted, size=168 (the hexa value changes from entry to entry)

Does anyone know what this about? Memory leak? Any ideas how to solve it if it is a problem?
Thanks!

How to&Answers:

There doesn’t seem to be a definitive answer on the net, so I had a look at the code for TextLayoutCache.cpp. Looks fine to me. It’s caching text layout data to improve performance, and there’s currently a fixed default cache size of 0.5MB defined in TextLayoutCache.h.

So if you’re changing layout text to a fixed set of values (<0.5MB), you won’t see the log message.

If you change text to dynamic values then eventually the cache will fill and the LRU (least recently used) cache entry is deleted, and you’ll see the log message. It’s just a debug message, not an error, not a leak. It’s a useful performance metric about how Android internals are handling our App.

Note that TextLayoutCache isn’t used in Android versions >= 5.

Answer:

I came across same issue when I was updating my textView values from handler using runnable &

I collected instance of textViews by findViewById() into variables, then updating values of textview by referring these collected instances.

So, as i observed I don’t need instance of that textview outside of my hander so I simply use findViewById()inside handler and updated my textviews.

write your findviewById() in context you need id.(talking about inside brackets of your function using it.. in my case.)

Hope this helps…