Figure: Diagnostic workflow: Compute visible range → Reuse a small cell pool → Update position and data
Figure: Diagnostic workflow: Compute visible range → Reuse a small cell pool → Update position and data

Cause and mechanism

ScrollRect is the uGUI component for scrolling a list. Creating every row, including those off screen, increases memory use and automatic layout work. Reuse a small set of visible rows and a few spare rows as the list scrolls. Measure the result because the way cost grows depends on the UI's structure.

Check and correct the setup

  1. For fixed-height lists, keep only visible cells plus a small buffer after profiling layout work.
    Change one variable, then remeasure
    Change one variable, then remeasure
  2. Compute content height and first visible index, then reuse cells and bind new data. Empty lists need zero height.
    Update position and displayed data
    Update position and displayed data
  3. Variable-height lists need a suitable height/index lookup. Handle resizing, fast jumps, last rows, and data changes; reset events and stale images.
    Update position and displayed data
    Update position and displayed data

Limits and verification

Removing automatic layout does not remove text/graphic update cost. Benefits depend on item count and updates.

A focused diagnostic setup

Use a fixed-height exercise without spacing/padding: one thousand rows at height twenty-four gives a content height of 24000, while only visible rows plus a buffer need cell objects.

Test in this order

  1. Derive and clamp the first visible data index from scroll position rather than allocating one cell per item.
    Update position and displayed data
    Update position and displayed data
  2. Refresh text, images, selection and event bindings when a cell changes data identity.
    Update position and displayed data
    Update position and displayed data
  3. Test empty/final rows, rapid scrolling, resizing and deletion, recalculating layout as needed.
    Update position and displayed data
    Update position and displayed data

Interpret the result

Variable-height content needs measured/cumulative heights rather than the fixed formula. Verify stable cell count and absence of stale images or click destinations.

Related explanations

References