Thanks, @eskimo for your help.
Yes, I still see the leaks caused by cycle reference?
Report Version: 7
Analysis Tool: /usr/bin/leaks
Physical footprint: 2720K
Physical footprint (peak): 2720K
----
leaks Report Version: 4.0
Process 43967: 787 nodes malloced for 85 KB
Process 43967: 8 leaks for 800 total leaked bytes.
8 (800 bytes) ROOT CYCLE: <CFRunLoopSource 0x600003034000> [192]
7 (608 bytes) ROOT CYCLE: 0x600003c30000 [224]
CYCLE BACK TO <CFRunLoopSource 0x600003034000> [192]
5 (352 bytes) ROOT CYCLE: 0x600002b34a80 [128]
2 (80 bytes) ROOT CYCLE: 0x600000536c80 [32]
1 (48 bytes) ROOT CYCLE: <__NSMallocBlock__ 0x600000b34c00> [48] CFNetwork <unknown-symbol> 0x7ff819c39000 + 1605859 0x7ff819dc10e3
1 (32 bytes) ROOT CYCLE: 0x600000536ce0 [32]
1 (112 bytes) <NSURL 0x600002e344d0> [112] "http://example.com/"
1 (32 bytes) 0x600000538140 [32]
Btw: If I use __bridge_transfer to replace the CFBridgingRelease in your code, then I get more leaks including the proxies.
CFArrayRef proxiesArray = CFNetworkCopyProxiesForAutoConfigurationScript((__bridge CFStringRef)pac, (__bridge CFURLRef) url, &err);
NSArray *proxies = (__bridge_transfer NSArray *)proxiesArray;
more leaks:
Report Version: 7
Analysis Tool: /usr/bin/leaks
Physical footprint: 2764K
Physical footprint (peak): 2764K
----
leaks Report Version: 4.0
Process 44061: 786 nodes malloced for 85 KB
Process 44061: 17 leaks for 1232 total leaked bytes.
17 (1.20K) ROOT CYCLE: <CFRunLoopSource 0x600003888000> [192]
16 (1.02K) ROOT CYCLE: 0x60000348c000 [224]
CYCLE BACK TO <CFRunLoopSource 0x600003888000> [192]
5 (352 bytes) ROOT CYCLE: 0x60000239c280 [128]
2 (80 bytes) ROOT CYCLE: 0x600000d9c220 [32]
1 (48 bytes) ROOT CYCLE: <__NSMallocBlock__ 0x60000039c000> [48] CFNetwork <unknown-symbol> 0x7ff819c39000 + 1605859 0x7ff819dc10e3
1 (32 bytes) ROOT CYCLE: 0x600000d9c280 [32]
1 (112 bytes) <NSURL 0x6000026980e0> [112] "http://example.com/"
9 (432 bytes) <CFArray 0x600001884200> [64] item count: 2
5 (240 bytes) <NSDictionary 0x6000018841c0> [64] item count: 3
1 (48 bytes) <CFString 0x600000384060> [48] length: 21 "kCFProxyPortNumberKey"
1 (48 bytes) <CFString 0x6000003840c0> [48] length: 16 "kCFProxyTypeHTTP"
1 (48 bytes) _list --> <CFString 0x600000384090> [48] length: 19 "kCFProxyHostNameKey"
1 (32 bytes) <CFString 0x600000d84060> [32] length: 11 "192.168.1.2"
3 (128 bytes) <NSDictionary 0x600000d84080> [32]
1 (48 bytes) _key --> <CFString 0x600000384030> [48] length: 15 "kCFProxyTypeKey"
1 (48 bytes) _obj --> <CFString 0x6000003840f0> [48] length: 16 "kCFProxyTypeNone"
1 (32 bytes) 0x600000d840a0 [32]
What's the difference between __bridge_transfer and CFBridgingRelease? Both are used to transfer ownership of a Core Foundation object to an Objective-C object, right?