@@ -685,43 +685,47 @@ - (NSNumber *)_numberForEntryAtIndex:(NSInteger)index {
685685#pragma mark - Working with Metadata
686686
687687- (void )saveMetadata {
688- [_lock lock ];
689-
690- NSDictionary *metadataDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
691- [_indexMap copy ], FICImageTableIndexMapKey,
692- [_sourceImageMap copy ], FICImageTableContextMapKey,
693- [[_MRUEntries array ] copy ], FICImageTableMRUArrayKey,
694- [_imageFormatDictionary copy ], FICImageTableFormatKey, nil ];
688+ @autoreleasepool {
689+ [_lock lock ];
690+
691+ NSDictionary *metadataDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
692+ [_indexMap copy ], FICImageTableIndexMapKey,
693+ [_sourceImageMap copy ], FICImageTableContextMapKey,
694+ [[_MRUEntries array ] copy ], FICImageTableMRUArrayKey,
695+ [_imageFormatDictionary copy ], FICImageTableFormatKey, nil ];
695696
696- __block int32_t metadataVersion = OSAtomicIncrement32 (&_metadataVersion);
697+ __block int32_t metadataVersion = OSAtomicIncrement32 (&_metadataVersion);
697698
698- [_lock unlock ];
699-
700- static dispatch_queue_t __metadataQueue = nil ;
701- static dispatch_once_t onceToken;
702- dispatch_once (&onceToken, ^{
703- __metadataQueue = dispatch_queue_create (" com.path.FastImageCache.ImageTableMetadataQueue" , NULL );
704- });
705-
706- dispatch_async (__metadataQueue, ^{
707- // Cancel serialization if a new metadata version is queued to be saved
708- if (metadataVersion != _metadataVersion) {
709- return ;
710- }
699+ [_lock unlock ];
700+
701+ static dispatch_queue_t __metadataQueue = nil ;
702+ static dispatch_once_t onceToken;
703+ dispatch_once (&onceToken, ^{
704+ __metadataQueue = dispatch_queue_create (" com.path.FastImageCache.ImageTableMetadataQueue" , NULL );
705+ });
706+
707+ dispatch_async (__metadataQueue, ^{
708+ // Cancel serialization if a new metadata version is queued to be saved
709+ if (metadataVersion != _metadataVersion) {
710+ return ;
711+ }
711712
712- NSData *data = [NSJSONSerialization dataWithJSONObject: metadataDictionary options: kNilOptions error: NULL ];
713+ @autoreleasepool {
714+ NSData *data = [NSJSONSerialization dataWithJSONObject: metadataDictionary options: kNilOptions error: NULL ];
713715
714- // Cancel disk writing if a new metadata version is queued to be saved
715- if (metadataVersion != _metadataVersion) {
716- return ;
717- }
716+ // Cancel disk writing if a new metadata version is queued to be saved
717+ if (metadataVersion != _metadataVersion) {
718+ return ;
719+ }
718720
719- BOOL fileWriteResult = [data writeToFile: [self metadataFilePath ] atomically: NO ];
720- if (fileWriteResult == NO ) {
721- NSString *message = [NSString stringWithFormat: @" *** FIC Error: %s couldn't write metadata for format %@ " , __PRETTY_FUNCTION__, [_imageFormat name ]];
722- [self .imageCache _logMessage: message];
723- }
724- });
721+ BOOL fileWriteResult = [data writeToFile: [self metadataFilePath ] atomically: NO ];
722+ if (fileWriteResult == NO ) {
723+ NSString *message = [NSString stringWithFormat: @" *** FIC Error: %s couldn't write metadata for format %@ " , __PRETTY_FUNCTION__, [_imageFormat name ]];
724+ [self .imageCache _logMessage: message];
725+ }
726+ }
727+ });
728+ }
725729}
726730
727731- (void )_loadMetadata {
0 commit comments