How to release Cocoa objects from Perl? (PerlObjCBridge or CamelBones)
How to release Cocoa objects from Perl? (PerlObjCBridge or CamelBones)
- Subject: How to release Cocoa objects from Perl? (PerlObjCBridge or CamelBones)
- From: Stephen Sample <email@hidden>
- Date: Thu, 6 Oct 2005 08:39:22 -0400
Thanks to Sherm's suggestion, I've now got Core Image scaling (and
cropping and sharpening) working from Perl.
However, the memory usage for Perl is going through the roof, so
there's pretty clearly a memory leak. Now that is not terribly
surprising, given that I'm never releasing any of the Cocoa objects
I'm creating during the image processing. And apparently Perl's
garbage collection won't release memory that's called through Cocoa.
But I still clearly need to do something about it: I can currently
get through 30 of the input images before Perl segfaults, and I'll be
working with something like 1,000 times as many images once this code
is done.
But looking at the examples for CamelBones (and any other tutorials
online), I can't figure out how to release the memory for the Cocoa
objects from within Perl. My case is somewhat different in that I
don't have a UI, and so I'm basically running a straight Perl.
I've tried the Cocoa-style
$cocoaObjectName->release;
but that gives me an error of
perl[5912] Unknown return type Vv
I've also tried the Perl-style
undef $cocoaObjectName;
that doesn't report any errors, but it also doesn't keep the memory
footprint from growing with each image pass.
If I create an NSAutoreleasePool with
my $cocoaAutoReleasePool = NSAutoreleasePool->alloc->init;
and pass an autorelease() message to each Cocoa object when I create
it, then I get all the
perl[5912] Unknown return type Vv
errors at once when I call
$cocoaAutoReleasePool->release;
at the end of the loop.
What am I missing? I feel like this should be something obvious, but
I can't see it.
Trying similar (but much simpler) code either all in Perl or all in
Cocoa works, so I think I've got a basic handle on how to release
objects in both idioms. It's just the intersection that I don't get.
I suppose I can write the scaling code as a standalone command-line
tool in XCode, and just call that as an external program from Perl,
but I'm hoping it'll be easier than that.
Thanks for putting up with all the newbie questions...
Ta,
-Stephen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden