Re: Workaround for framework leaks?
Gregory Weston <[email protected]> Sat, 14 Aug 2010 15:50:35 -0400
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
Christiaan Hofman wrote: > I have found some leaks in the system frameworks. I know exactly what property is over-retained when a new object of certain classes is created. Now my question is whether it is possible using this knowledge to avoid this leak? I could imagine to just send a release to the property. However that may be dangerous, because when Apple fixes the bug in the future that would lead to an over-release (and a crash). So would there be some way to avoid that? Well, I would say the first thing that needs to happen is that you have to be really sure that you're seeing what you think you're seeing, and *not* misinterpreting a legitimate and intentional behavior. Overwhelmingly that seems to be the case for threads that start, "I've found some leaks in the system frameworks...." If you identified some of these leaks here, it might be that some others could verify your observations or explain them. Next is that any bugs really need to be submitted to Apple. As for dealing with them in your own code: The best solution is to find an alternative technique that sidesteps the bug. It may not result in theoretically optimal code, but it's much better than violating the memory contract by trying to second-guess the frameworks. Try really hard to go this route. It's very rare that there's exactly one way to do something. Failing that, and again making absolutely sure that this is *really* a bug, I would say that you might be able to get by by coming up with a very rigorous and detectable set of circumstances under which the bug exists and deal with the issue only when those circumstances hold true. Needless to say, one of those circumstances is going to be the precise versions of the specific framework(s) involved. If you detect any deviations from those conditions, don't mess with it.