Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Headless Cocoa/Java app - autorelease - solution ?



Read up on auto-release pools. .
<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/ Concepts/AutoreleasePools.html#//apple_ref/doc/uid/20000047>


Modified the below...

public class Foo() extends NSPureApplication {

    private doStuff(){
        int myPool = NSAutoreleasePool.push();

        NSImage image = new NSImage(new URL("http://someplace...";));
        // do stuff w/image.

        NSAutoreleasePool.pop(myPool);
        return;
    }

public static void main(String[] args){
NSApplication app = NSApplication.sharedApplication();
NSWindow dummy = new NSWindow();
NSGraphicsContext.currentContext().setImageInterpolation (NSGraphicsContext.ImageInterpolationHigh);
for(cnt = 0;cnt < 10; ++cnt){
doStuff();
}
Object o = new Object();
o.toString(); // place to set a breakpoint ;)
}
}


Also you are not starting the applications runloop so it won't be attempting to many any auto-release pools or process any events but in this case that is likely ok ... without knowing what you are trying to do.

-Shawn


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Headless Cocoa/Java app - autorelease (From: Michael Hall <email@hidden>)
 >Re: Headless Cocoa/Java app - autorelease - solution ? (From: String Larson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.