spotify / spotify/SPTPersistentCache
Cache fails to store large files
Nobody has claimed this yet.
- Dominant language
- Objective-C
- Stars
- 1.2k
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
Whenever we try to save large files (>100MB, actual size depends on device capabilities) to cache, nothing happens except console log message like
*** mach_vm_map(size=997462016) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
The problem is in SPTPersistentCache method
- (NSError *)storeDataSync:(NSData *)data
forKey:(NSString *)key
ttl:(NSUInteger)ttl
locked:(BOOL)isLocked
withCallback:(SPTPersistentCacheResponseCallback)callback
onQueue:(dispatch_queue_t)queue
The following code does not work for large rawDataLength
NSMutableData *rawData = [NSMutableData dataWithCapacity:rawDataLength];
One way to handle large amounts of data is to fill temporary file with relatively small blocks of data first and then writing it atomically to target filePath
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SPTPersistentCache's storeDataSync:forKey:ttl:locked:withCallback:onQueue: method and inspect the NSMutableData allocation using rawDataLength. Reproduce the failure with data over 100MB, then verify that large data can be cached successfully and that the write remains atomic. No specific file or test is mentioned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100