• 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
Memory Leak in JNI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory Leak in JNI


  • Subject: Memory Leak in JNI
  • From: Bjorn Roche <email@hidden>
  • Date: Tue, 27 Mar 2007 10:09:50 -0400

Hey all,

I've been chatting with folks on the java dev list about a problem with technote 2147 about adding an NSView to Java using Java's CocoaComponent class. The original discussion was a bit confused, but if you care to read it, it's here: http://lists.apple.com/archives/ java-dev/2007/Mar/msg00280.html

To summarize, when I create an NSView and show it in Java, using the directions in technote 2147, and then remove it from Java's containment hierarchy, the NSView's dealloc method is never called, resulting in a memory leak. I've filed a bug report, but I thought someone here might have a suggestion, or know more about the Objective-C side of things.... my Objective-C is not so good, but I have read all the memory management documents, so I understadn retain/ release/autorelease.

I overwrote the NSView's retain/release/dealloc functions to see if I could figure out what was going on:

- (id) retain
{
   NSLog( @"---< retain >---%@, %d", self, [super retainCount] );
   [super retain];
   NSLog( @"---< retain >---%@, %d", self, [super retainCount] );
   return self;
}

- (id) release
{
   NSLog( @"---< release >---%@, %d", self, [super retainCount] );
   [super release];
   NSLog( @"---< release >---%@, %d", self, [super retainCount] );
   return self;
}
- (void) dealloc
{
   NSLog( @"---< dealloc >---%@, %d", self, [super retainCount] );
   [transform release];
   //delete audioBlock;
   [super dealloc];
}

The lowest I've managed to get the retaincount is 1, and that took a manual [self removeFromSuperview], but even then, the object is still retained. I'm hoping I'm just doing something really wrong here, but I've been staring at this for hours (days?) and I don't think I am. This is a major show-stopper for me as it could cause huge memory leaks, so any suggestions are appreciated.

I've also filed a bug report (#5091080) if it matters.

	bjorn

-----------------------------
Bjorn Roche
XO Wave
Digital Audio Production and Post-Production Software
http://www.xowave.com
http://blog.bjornroche.com
http://myspace.com/xowave


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Solved: NSHTTPCookieManagerCookiesChangedNotification
  • Next by Date: Re: MacCode subversion repo
  • Previous by thread: Re: MacCode subversion repo
  • Next by thread: Proper Way to "Unload" a Loaded Nib w/Bindings
  • Index(es):
    • Date
    • Thread