From: Arno P. <ar...@pu...> - 2012-07-18 04:24:30
|
not doing a CFRelease in the finalizer of CFType definitely is not OK and will leak memory. I looked at the implementation of UIGraphics and I don't see anything that would conflict with the finalizer doing the CFRelease (i.e., I don't think there is a double-release). HOWEVER, the finalizer is run by a special finalizer thread (as per Java spec). In order to assure that CFRelease happens on the UI thread one needs a helper object to do just that. What Paul commented out didn't do this and perhaps that was the source of his problem. I have just committed a patch. Please check if this fixes your problems and addresses your concerns. Arno On 7/17/12 12:26 PM, Markus Heberling wrote: > Hi, > > I did the implementation of CFType with the release in the finalizer. The idea was, that the GC should take care of CFType-Types, so CFRelease was removed from the Java API. I also build the workaround in the popContext function, since without it the release would be called one time too much. Maybe the workaround was bogus, but I would definilty choose option 2) so that the GC can handle CFType-Types. I don't know what the current implemenation does, since I'm currently not using any CFType stuff in my xmlvm projects, but if we could get option 2) correctly implemented, that would be great. :) > > Regards, > Markus > > Am 17.07.2012 um 20:51 schrieb JR Schmidt: > >> I believe that CFRelease is still needed in CFType.finalize() for reasons OTHER than UIGraphics. For example, CGBitmapContext.create() generates a CGBitmapConextRef. Currently there is no corresponding ".release()" method defined in the Java interface for CGBitmapContext (e.g. no way to call CGContextRelease). A similar issue exists with CGColorSpaceRelease. It seems the logic here was that context would be released in the finalize method derived from CFType. But if this is commented out, the context is never released -- and there is no mechanism to do so. >> >> Assuming I understand your previous post, it would thus seem to me that EITHER, >> 1) A release method needs to be defined for CGBitmapContext (and other similar methods), or >> 2) The call to CFRelease in CFType.finalize() needs to be restored, which may entail some changes in UIGraphics >> >> The new iOS interface is not an option for me, as it current does not appear to implement CGBitmapContext and several other objects. >> >> One fairly simple workaround is to define a Java class with a static CFRelease(...) method and implement this in C. This seems to work for me, but its a bit of a hack for something that seems fairly crucial / fundamental. >> >> JR >> >> On 7/17/2012 1:25 PM, Paul Poley wrote: >>> I believe the reason I commented out the "CFRelease" in CFType.finalize() is that it was only there in the first place because of a bug in UIGraphics. Namely, popContext() was popping the context & then releasing the current context, which is wrong & a different context altogether. It should've been releasing the context that was popped, so I fixed that. >>> >>> Then, the bug in CFType.finalize() which called CFRelease could be fixed. I.e. if it was left in there, it'd be incorrectly released twice. Note that CGContextRelease is equivalent to CFRelease. >>> >>> Thanks, >>> Paul >>> >> >> -- >> J.R. Schmidt >> WebMO, LLC >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ >> xmlvm-users mailing list >> xml...@li... >> https://lists.sourceforge.net/lists/listinfo/xmlvm-users >> >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> >> >> _______________________________________________ >> xmlvm-users mailing list >> xml...@li... >> https://lists.sourceforge.net/lists/listinfo/xmlvm-users |