naptics / PlainPing

a very plain ping interface in swift
MIT License
58 stars 21 forks source link

Fix potential retain cycle #33

Closed Sega-Zero closed 1 year ago

Sega-Zero commented 1 year ago

Strong reference to delegate will produce a retain cycle, so PlainPing instance will never be deallocated

dstd commented 1 year ago

It's quite a breaking change. Actually it makes PlainPing non-working – because all strong links are released right after the return from the call to ping method and the instance of PlainPing gets destroyed.

rholstad commented 1 year ago

@seeppp yes, this change causes SimplePing to deallocate immediately which means that PlainPing.ping never calls its completion block. Using the Allocations profiler, it doesn't seem like this change is needed at all. Both PlainPing and SimplePing are deallocated just fine already.