mickeyl / LTSupportAutomotive

An iOS / watchOS / macOS support library for OBD2, VIN-Decoding, and more.
MIT License
212 stars 59 forks source link

Memory Leak / Issue ? SIGSEGV: SEGV_ACCERR #23

Open Skyb0rg opened 5 years ago

Skyb0rg commented 5 years ago
bildschirmfoto 2019-01-03 um 19 22 54

sometimes i get this error, maybee you can help me or improve the pod?

Skyb0rg commented 5 years ago

Hi i have a solution for this problem:

create dealloc and set delegate to nil

-(void)dealloc {
    _delegate = nil;
}

update: -(void)characteristicDidUpdateValue

{
    @try {
        NSData* value = _characteristic.value;
        [_buffer appendData:value];
        @synchronized(self) {
            [self.delegate stream:self handleEvent:NSStreamEventHasBytesAvailable];
        }
    }
    @catch (NSException *exception) {
        NSLog(@"%@", exception.reason);
    }
}

tested about 8 hours, this error didn´t happend again, but got another error (i will report it in another Issue )

maybee we only need to update this code.

@synchronized(self) {
            [self.delegate stream:self handleEvent:NSStreamEventHasBytesAvailable];
}

do the same in -(void)characteristicDidWriteValue

-(void)characteristicDidWriteValue
{
    @try {
        @synchronized(self) {
            [self.delegate stream:self handleEvent:NSStreamEventHasSpaceAvailable];
        }
    }
    @catch (NSException *exception) {
        NSLog(@"%@", exception.reason);
    }

}

Hope this helps someone!!!

i will create a push-request the next days.

Skyb0rg commented 5 years ago

@synchronized(self) is not the solution. Now i test with the serial dispatchqueue in the transporter.

Skyb0rg commented 5 years ago

created pull request for the solution. #26