New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 600699 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Mojo RouterImpl's HashMap causes unnecessary gc due to boxing/unboxing

Project Member Reported by joh...@chromium.org, Apr 5 2016

Issue description

org.chromium.mojo.bindings.RouterImpl uses a HashMap<Long, MessageReceiver> to store the callbacks for all Mojo method calls.

Lint complains that this causes unnecessary garbage collection thrashing due to boxing/unboxing of the long map keys, and instead recommends to use an android.util.LongSparseArray.

But LongSparseArray is probably not suitable either, since the documentation says it's "not intended to be appropriate for data structures that may contain large numbers of items"[1].

Instead, we probably want to use a specialized "LongHashMap" class which combines the benefits of both, such as [2].

In the meantime, the lint warning will be suppressed.

[1]: http://developer.android.com/reference/android/util/LongSparseArray.html

[2]: https://github.com/greenrobot/essentials/blob/master/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java
 
Project Member

Comment 1 by bugdroid1@chromium.org, Apr 5 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4d8bdcdeae1ffd4e969e65c8cc87b4491c4d3d1f

commit 4d8bdcdeae1ffd4e969e65c8cc87b4491c4d3d1f
Author: johnme <johnme@chromium.org>
Date: Tue Apr 05 17:12:39 2016

Suppress SparseArray lint warning in Mojo RouterImpl

org.chromium.mojo.bindings.RouterImpl uses a HashMap<Long, MessageReceiver> to store the callbacks for all Mojo method calls.

Lint complains that this causes unnecessary garbage collection thrashing due to boxing/unboxing of the long map keys, and instead recommends to use an android.util.LongSparseArray.

But LongSparseArray is probably not suitable either, since the documentation says it's "not intended to be appropriate for data structures that may contain large numbers of items".

This patch suppresses the warning for now.

BUG=600699

Review URL: https://codereview.chromium.org/1850793002

Cr-Commit-Position: refs/heads/master@{#385201}

[modify] https://crrev.com/4d8bdcdeae1ffd4e969e65c8cc87b4491c4d3d1f/mojo/public/java/bindings/src/org/chromium/mojo/bindings/RouterImpl.java

Components: -Internals>Mojo Internals>Mojo>Bindings
Status: Available (was: Untriaged)
Still valid, as RouterImpl still has a HashMap with boxed longs as keys. LongSparseArray may in fact be appropriate as the number of pending responses on an endpoint at any given time should not really grow too large.

Sign in to add a comment