Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache fails to store large files #85

Open
vilinskiy-playdayteam opened this issue Dec 20, 2016 · 1 comment
Open

Cache fails to store large files #85

vilinskiy-playdayteam opened this issue Dec 20, 2016 · 1 comment
Labels

Comments

@vilinskiy-playdayteam
Copy link

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

@8W9aG 8W9aG added the bug label Dec 20, 2016
@8W9aG
Copy link
Contributor

8W9aG commented Dec 20, 2016

Thanks I'll look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants