• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Headless Cocoa/Java app - autorelease
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Headless Cocoa/Java app - autorelease


  • Subject: Re: Headless Cocoa/Java app - autorelease
  • From: String Larson <email@hidden>
  • Date: Mon, 2 May 2005 21:50:16 -0500

That's a great question.
The NSAutorelease stuff in Java is kinda vague.
The Apple docs say:
<x-tad-bigger>int myPool = NSAutoreleasePool.push();
// Your code here
NSAutoreleasePool.pop(myPool);

So, I *assume* the pop() will release any underlying objects that have sent a release message w/in the Obj-C code.

If I have:

public class Foo() extends Thread{
public void run(){
int pool = NSAutoreleasePool.push();
doStuff();
NSAutoreleasePool.pop(pool);
}

private doStuff(){
NSImage image = new NSImage(new URL("http://someplace..."));
// do stuff w/image.
return;
}
}

Everything should be ok (if not right away, at least on the next GC), no?


</x-tad-bigger>

On May 2, 2005, at 6:22 PM, John Stiles wrote:

What exactly causes the AutoreleasePool to be freed when the Java object is garbage collected? It sounds like this is not happening for whatever reason.


On May 2, 2005, at 2:20 PM, String Larson wrote:

Thanks.

I had wrapped all my threads with pools (push/pop) just to try and see that was happening. I'm not getting the 'just leaking' messages any longer.
However, memory is not being released when the Java object containing NSImages is GC'd and/or the pool is released/popped.

I've been stripping things down - running a Java class w/o JBoss and as a single thread to eliminate variables. Still no luck.

Its behaving as if NSImage is leaking. It seems there is an OS thread (AppKit ?) that is alloc-ing NSViews and NSImageCacheViews w/o a pool in place these don't seem to get collected when the NSImage is GC'd.

I'm going to put together a simple working example that can be posted here.
Any detailed info on AppKit/etc. would be helpful/welcome.

Thanks.
 _______________________________________________
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

  • Follow-Ups:
    • Re: Headless Cocoa/Java app - autorelease
      • From: Michael Hall <email@hidden>
    • Re: Headless Cocoa/Java app - autorelease
      • From: Michael Hall <email@hidden>
    • Re: Headless Cocoa/Java app - autorelease
      • From: Michael Hall <email@hidden>
References: 
 >Headless Cocoa/Java app - autorelease (From: String Larson <email@hidden>)
 >Re: Headless Cocoa/Java app - autorelease (From: Shawn Erickson <email@hidden>)
 >Re: Headless Cocoa/Java app - autorelease (From: String Larson <email@hidden>)
 >Re: Headless Cocoa/Java app - autorelease (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Detecting the Option key on selecting a menuitem
  • Next by Date: Re: Programatically adding small checkboxes
  • Previous by thread: Re: Headless Cocoa/Java app - autorelease
  • Next by thread: Re: Headless Cocoa/Java app - autorelease
  • Index(es):
    • Date
    • Thread