NSPipe leaks.
| Originator: | GRMrGecko | ||
| Number: | rdar://13277215 | Date Originated: | 22-Feb-2013 05:14 PM |
| Status: | Open | Resolved: | |
| Product: | Mac OS X | Product Version: | 10.8.2/12C60 |
| Classification: | Other Bug | Reproducible: | Always |
22-Feb-2013 05:14 PM James Coleman: Summary: I have a daemon I wrote which uses NSPipes and over the time of it running, eventually the pipes on my system is taken. I have created a project which rapidly creates NSPipes and uses them the same way my daemon does and have done lots of tests such as making it ARC based and verifying my code itself isn't leaking. Each attempt shows in Instruments that it is leaking. The only way I can think of getting around this is possibly writing my own version of NSTask/NSPipe which does not leak or having my daemon automatically re-launch itself to release the memory/pipes which were taken up. Right now, I am manually using killall to have launchd relaunch it when I feel as if I'm getting close to the limit. Just to provide some humor... You've got some leaky pipes there. See the attached main file for my test. 22-Feb-2013 05:14 PM James Coleman: 'main.m' was successfully uploaded
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Ok, finally found an answer to the leak. It leaks when you call [[notification object] readInBackgroundAndNotify]; after the end of file was sent. If you move the call to end of if ([data length]!=0) { instead of at the end of the method, it does not leak anymore.
This to me sounds like as if NSPipe should be removing that readInBackground loop as it's being released.
At least I got rid of that leaky pipe in my daemon.