question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OOM with the new sheet approach

See original GitHub issue
  • Version of the library: Current SNAPSHOT
  • Affected devices: Low memory devices
  • Affected versions: Potentially all

I ran into an OOM with one of my old devices when opening an Activity with an EmojiTextView. This is due to the emoji Bitmap being really large when decoded. I can’t really use it in production like that sadly.

I tried:

I can’t come up with a solution at this point. Maybe someone else has an idea? Otherwise: Should we revert?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:36 (28 by maintainers)

github_iconTop GitHub Comments

9reactions
akwizgrancommented, Jul 27, 2018

I’ve experimented with a few approaches to this and found a solution that seems to work well.

The generator cuts the sprite sheet into strips, one sprite wide. (This was easier to implement than creating a sheet for each category.) The strips are loaded on demand and held by SoftReferences, so they’re released when the app’s under memory pressure. To avoid constantly loading and releasing strips, the most recently used emoji are cached without keeping the whole strip.

Here’s my branch. If you think this approach sounds reasonable I’ll open a PR: https://github.com/vanniktech/Emoji/compare/master...akwizgran:sprite-strips-soft-refs-lru-cache

On devices with low-density screens, it’s also possible to scale the strips (or sheets) by a factor of 2 when loading them, which reduces the memory overhead without increasing the APK size. However, this increases the CPU cost of loading a strip. This branch includes scaling as a separate commit: https://github.com/vanniktech/Emoji/compare/master...akwizgran:sprite-strips-soft-refs-lru-cache-scaling

3reactions
rocboronatcommented, Aug 10, 2018

Good news there: we are at 6,1% with 0 crashes. IMHO, move on with the PR of the branch sprite-strips-soft-refs-lru-cache. Congrats and thanks for that magnificent work, @akwizgran!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Postpartum hemorrhage: Management approaches requiring ...
This topic will discuss treatment approaches for PPH that require laparotomy. Medical and minimally invasive management of patients with PPH ...
Read more >
FACT SHEET: The American Jobs Plan | The White House
This is the moment to reimagine and rebuild a new economy. The American Jobs Plan is an investment in America that will create...
Read more >
Infection Control: Healthcare Settings | Mpox | Poxvirus - CDC
A patient with suspected or confirmed mpox infection should be placed in a single-person room; special air handling is not required.
Read more >
How to Move Worksheets to Other Workbooks in Excel 2016
If you prefer a more direct approach, you can move or copy sheets between open workbooks by dragging the sheet tabs from one...
Read more >
Infection Prevention and Control - The Joint Commission
Approach to Standards Compliance ... follow the hierarchical approach to determine infection control requirements that are specific to their organizations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found