0

I have a problem with memory full with RNDecryptor (+) in a cycle "for" i call this method es:

for (int i=0;  i < [datasource fileCount]; i++) {
    ...
    datacrypto = [RNDecryptor decryptData:datacrypto withSettings:kRNCryptorAES256Settings password:passcode error:nil];
    ....
}

RNDecryptor allocates memory but the calls do not empty and sooner or later there is no more free memory and CRASH ... its possible dealloc +[RNDecriptor...] between calls or otherwise as a solution ??

thank you.

Marino
  • 1
  • 4
  • The problem is probably that you're trying to decrypt too much data in memory. What do you do with the `NSData` you get from that method? – orkoden Feb 03 '15 at 12:31
  • then : [datacrypto writeToFile:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), fileName] atomically:YES]; ... – Marino Feb 03 '15 at 13:10
  • 1
    i have resolved with : @autoreleasepool { // Code that creates autoreleased objects. } bye. – Marino Feb 03 '15 at 19:19
  • 1
    @Marino ...and you're presumably on top of why that resolves the problem? Or would an answer still be helpful, regardless of the fact that you already know the fix? – Tommy Feb 03 '15 at 21:06
  • @Tommy the problem is resolved. – Marino Feb 03 '15 at 22:12

1 Answers1

-1

Here's the implementation of the method.

+ (NSData *)decryptData:(NSData *)theCipherText withSettings:(RNCryptorSettings)settings password:(NSString *)aPassword error:(NSError **)anError
{
    RNDecryptor *cryptor = [[self alloc] initWithPassword:aPassword
                                            handler:^(RNCryptor *c, NSData *d) {}];
    cryptor.settings = settings;
    return [self synchronousResultForCryptor:cryptor data:theCipherText error:anError];
}

It's no a singleton or is there any other branch? If not, you better implement your own singleton pattern.

Ryan
  • 4,799
  • 1
  • 29
  • 56