Skip to content

iron-list (v2) crashes chrome (out-of-memory exception) when working with large lists #518

Description

@gopherkhan

Description

I'm using iron-list (v2) to render lists of log data over time. Depending on how noisy the entity being monitored is, the list can grow quite large.

I've found after supplying two lists of 30k+ elements to the iron list, the browser crashes.

This is likely due to the list's use of array-splice.html, which uses a Levenshtein edit distance function (calcEditDistances) to determine which elements need replacing.

The function creates an NxN array as it workspace, which for a 30,000 element list becomes a 900,000,000 entity grid, and consumes 1gig of heap.

Relevant code in array-splice.html:

function calcEditDistances(current, currentStart, currentEnd,
                              old, oldStart, oldEnd) {
    // "Deletion" columns
    let rowCount = oldEnd - oldStart + 1;
    let columnCount = currentEnd - currentStart + 1;
    let distances = new Array(rowCount);

    // "Addition" rows. Initialize null column.
    for (let i = 0; i < rowCount; i++) { // crashes reliably here
      distances[i] = new Array(columnCount);
      distances[i][0] = i;
    }

Expected outcome

Since the list was working in v1.x, the iron list should still take whatever I throw at it.

Actual outcome

Browser crash.

Live Demo

I'm not at liberty to share

Steps to reproduce

  1. Put a sized iron-list element in the page, with a really simple template, a la:
iron-list {
        overflow: auto;
        height: calc(100vh - 286px);
      }
...
<iron-list id="ironList" items="[[data]]">
      <template>
        <div style="height: 24px">Hey hey hey!</div>
      </template>

Note: You can omit any template bindings in the row div.

  1. Add a button to supply 30k elements on click
  2. Click the button twice

Browsers Affected

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions