Skip to content

Fix XMB thumbnail memory exhaustion on low-memory devices#18854

Open
ma-moon wants to merge 1 commit intolibretro:masterfrom
ma-moon:fix-xmb-memory-clean
Open

Fix XMB thumbnail memory exhaustion on low-memory devices#18854
ma-moon wants to merge 1 commit intolibretro:masterfrom
ma-moon:fix-xmb-memory-clean

Conversation

@ma-moon
Copy link
Copy Markdown

@ma-moon ma-moon commented Mar 24, 2026

Description

This PR fixes severe memory exhaustion issues in the XMB menu when loading thumbnails on low-memory devices (e.g., embedded systems, older phones).
This is a cleaned-up version of the changes originally proposed in #18828, squashed into a single commit based on the latest master.

Changes

  • Concurrency Control: Limits concurrent thumbnail load tasks to prevent memory spikes (capped at 2-4 active tasks).
  • Scroll Optimization: Implements rapid scroll detection to defer loading during fast navigation, prioritizing responsiveness.
  • Memory Management: Aggressively frees off-screen textures to reduce GPU memory pressure.
  • Load Rejection: Adds early rejection logic when load capacity is reached to prevent queue buildup.

Related Issue

Fixes #6747

Testing

Tested on low-memory environments; verified stable memory usage during rapid scrolling and large library navigation.

@ma-moon
Copy link
Copy Markdown
Author

ma-moon commented Mar 26, 2026

@maintainers

This is the clean, rebased version of #18828.

  • All changes squashed into one commit
  • Based on latest master
  • CI is green
  • No merge conflicts

Ready for merge. Please review when you have time.

Thanks!

Best,
ForgeCore

@ma-moon
Copy link
Copy Markdown
Author

ma-moon commented Mar 26, 2026

@maintainers

All CI checks are green. No merge conflicts.

Please merge when you have time. Thanks!

Best,
ForgeCore

1 similar comment
@ma-moon
Copy link
Copy Markdown
Author

ma-moon commented Mar 26, 2026

@maintainers

All CI checks are green. No merge conflicts.

Please merge when you have time. Thanks!

Best,
ForgeCore

@ma-moon
Copy link
Copy Markdown
Author

ma-moon commented Mar 27, 2026

CI passed, ready for review. Could you take a look when you have time? Thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to apply this beyond XMB? The other themes load thumbnails too, maybe they'd apply?

Comment on lines +9233 to +9239
#if defined(HAVE_OPENGLES) || defined(__SWITCH__) || defined(ANDROID)
/* Low-memory platforms: limit to 2 concurrent loads */
gfx_thumbnail_set_max_concurrent_loads(2);
#else
/* Desktop platforms: allow 4 concurrent loads */
gfx_thumbnail_set_max_concurrent_loads(4);
#endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding 2 vs 4 indicates it could likely live better as a defined macro that could be changed during compilation flags.

#ifndef GFX_THUMBNAIL_MAX_CONCURRENT_LOADS
#define GFX_THUMBNAIL_MAX_CONCURRENT_LOADS 4
#endif

Comment on lines +131 to +132
/* LOW-MEMORY FIX: Maximum number of concurrent thumbnail load tasks
* Helps prevent memory exhaustion on low-memory devices (RPi, Switch, etc.) */
Copy link
Copy Markdown
Member

@RobLoach RobLoach Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing LOW-MEMORY FIX everywhere is unnecessary.

Suggested change
/* LOW-MEMORY FIX: Maximum number of concurrent thumbnail load tasks
* Helps prevent memory exhaustion on low-memory devices (RPi, Switch, etc.) */
/* Limits the number of thumbnails that can be loaded concurrently.
* Helps prevent memory exhaustion on low-memory devices (RPi, Switch, etc.) */

Comment on lines +159 to +160
/* LOW-MEMORY FIX: Concurrent load management API */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. It's covered in the doxygen docs of the function definitions.

Suggested change
/* LOW-MEMORY FIX: Concurrent load management API */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty: $170] XMB always stops displaying images with low-power/memory (rpi, Switch, Classic, others)

2 participants