Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Cache problem! #52

Open
illukinati opened this issue Jun 11, 2021 · 1 comment
Open

Cache problem! #52

illukinati opened this issue Jun 11, 2021 · 1 comment

Comments

@illukinati
Copy link

There is an issue when you load up the PDFs many times the app will crash due to the memory problem.
Cache problem only happened in iOS.

* thread #13, name = 'io.flutter.1.io', stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=1850 MB, unused=0x0)
    frame #0: 0x00000001f23c9138 libsystem_platform.dylib`_platform_memmove + 88
libsystem_platform.dylib`_platform_memmove:
->  0x1f23c9138 <+88>:  stnp   x8, x9, [x3]
    0x1f23c913c <+92>:  stnp   x10, x11, [x3, #0x10]
    0x1f23c9140 <+96>:  add    x3, x3, #0x20             ; =0x20 
    0x1f23c9144 <+100>: ldnp   x8, x9, [x1]
Target 0: (Runner) stopped.
@illukinati
Copy link
Author

I remove this part from the library, and it works just fine.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *temporaryDirectory = [paths objectAtIndex:0];
    NSString *filePathAndDirectory = [temporaryDirectory stringByAppendingPathComponent:kDirectory];
    NSError *error;

    // Clear cache folder
    if ([[NSFileManager defaultManager] fileExistsAtPath:filePathAndDirectory]) {
        NSLog(@"[FlutterPluginPDFViewer] Removing old documents cache");
        [[NSFileManager defaultManager] removeItemAtPath:filePathAndDirectory error:&error];
    }

    if (![[NSFileManager defaultManager] createDirectoryAtPath:filePathAndDirectory
                                   withIntermediateDirectories:YES
                                                    attributes:nil
                                                         error:&error])
    {
        NSLog(@"Create directory error: %@", error);
        return nil;
    }
    // Generate random file size for this document

    kFileName = [[NSUUID UUID] UUIDString];

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

No branches or pull requests

1 participant