GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — storeCacheType .disk no longer keeps disk-cache hits out of the memory cache (regression in 5.21.6) · Issue #3893 · SDWebImage/SDWebImage

storeCacheType .disk no longer keeps disk-cache hits out of the memory cache (regression in 5.21.6) #3893

New issue
Copy link
New issue
Copy link
Open
#3894
Open
storeCacheType .disk no longer keeps disk-cache hits out of the memory cache (regression in 5.21.6)#3893
#3894
Copy link

Description

@oeddyo
oeddyo
opened on Nov 2, 2026
Issue body actions

New Issue Checklist

  • I have read and understood the CONTRIBUTING guide
  • I have read the Documentation
  • I have searched for a similar issue in the project and found none

Issue Info

Info Value
Platform Name ios / macos
Platform Version iOS 27.2 (device), iOS 26.5 (simulator), macOS 26.5.1
SDWebImage Version 5.21.6, 5.21.7, master (c3ad5e1). 5.21.5 is fine.
Integration Method Swift Package Manager (repro); prebuilt framework inside expo-image (app)
Xcode Version Xcode 26.6
Repro rate all the time (100%)
Repro with our demo prj not tried; the repro is a 40-line command-line package
Demo project link https://gist.github.com/oeddyo/2a9c5cabe5d7833fbd495b9d01ebf09b

Issue Description and Steps

Since 5.21.6, a load whose context sets storeCacheType to .disk writes the image to the memory cache when the disk cache serves it. 5.21.5 leaves the memory cache alone.

Repro: https://gist.github.com/oeddyo/2a9c5cabe5d7833fbd495b9d01ebf09b. ./run.sh builds it against 5.21.5, 5.21.6, 5.21.7 and master.

  1. Store image data in the disk cache only: storeImageData(toDisk:forKey:).
  2. Load its URL with .queryCacheType and .storeCacheType both .disk. The URL is never fetched; the disk cache answers.
  3. Check imageFromMemoryCache(forKey:).
let diskOnly: [SDWebImageContextOption: Any] = [
  .queryCacheType: SDImageCacheType.disk.rawValue,
  .storeCacheType: SDImageCacheType.disk.rawValue,
]
manager.loadImage(with: url, options: [], context: diskOnly, progress: nil) { image, _, _, cacheType, _, _ in
  // cacheType == .disk, and on 5.21.6+ this is true:
  print(cache.imageFromMemoryCache(forKey: key) != nil)
}
Version Served from In memory after the load
5.21.5 disk false
5.21.6 disk true
5.21.7 disk true
master (c3ad5e1) disk true

The iOS simulator gives the same results, built from source.

Cause. 84c74d1 (#3866) added a write-back to SDWebImageManager in callCacheProcessForOperation and callOriginalCacheProcessForOperation:

// Write back the disk image into memory cache, with the correct key
if (cacheType == SDImageCacheTypeDisk) {
    // Sync
    [imageCache storeImage:cachedImage imageData:nil forKey:key cacheType:SDImageCacheTypeMemory completion:nil];
}

The sync it replaced, in SDImageCache's disk query, ran only when storeCacheType was .all or .memory (#3157). The new write-back doesn't check storeCacheType. In SDImageCache.m the old check is still computed (shouldCacheToMemory, master lines 659–662) but no longer used.

A disk-only query never reads the memory cache (shouldQueryDiskOnly), so these entries are never served; they only hold memory.

Impact. We hit this in an iOS app through expo-image, whose cachePolicy: "disk" maps to .disk for both context options. With the default maxMemoryCost of 0 (no limit), every full-size photo viewed from the disk cache stayed in memory. On an iPhone 17 Pro, a gallery of 24 MP photos was killed after about 14 of them. Setting maxMemoryCost avoids the crash, but .disk no longer keeps images out of memory.

A comment on #3866 reports another effect of the same write-back: a thumbnail stored in memory under the original's key.

Expected. The write-back honours storeCacheType: it writes to memory only when storeCacheType is .all or .memory, or when it is not set.

Activity

  1. sawalon commented on Nov 20, 2026

    @sawalon
    sawalon
    on Nov 20, 2026
    More actions

    Related: #3896 fixes a separate problem in the same write-back path since 5.21.6 — a thumbnail load can overwrite the full size image under the original memory key.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.