From: Duncan M. <du...@on...> - 2009-07-06 20:21:20
|
On 6 Jul 2009, at 20:22, Scott Thompson wrote: >> CFRelease imageSource results in a segfault or bus error. For low >> iteration counts this happens after the test has finished, increasing >> the count makes it happen during the loop, suggesting a problem >> during >> garbage collection I think. >> >> If I don't CFRelease imageSource then I run out of memory to load any >> more images after about 4000 iterations with my test file. > It does sound like a problems somewhere in the garbage collector. > It seems like the garbage collector is trying to keep the reference > that rightfully belongs to you. > > Have you tried taking out your calls to CFRelease and forcing the > garbage collector to run every iteration through the loop as a test > (say by calling GC.garbage_collect). Seems a bit extreme, but it > would let you know if the ruby proxy wants to "own" your CG objects > for you. 1.upto(10000) do |i| imageSource = CGImageSourceCreateWithURL(NSURL.fileURLWithPath('testdata/pot pourri/ blood.jpg'), nil) image = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) #CFRelease image #CFRelease imageSource ObjectSpace.garbage_collect end does not crash but runs out of memory as fast as it does without the GC (well, actually much slower, as the GC is slow, but at the same number of iterations). Am I right in thinking that RubyCococa is now effectively an Apple project, and so comes with the usual high level of support ;-? D |