Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Releasing objects obtained from Java

Releasing objects obtained from Java
Thread Tools
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status: Offline
Reply With Quote
Jan 29, 2004, 10:23 PM
 
Is there something wrong with this code? When I uncomment the two release statements at the end, i get a SIGBUS about 1 in 3 times and the application quits.

Code:
id vector = [[NSClassFromString(@"java.util.Vector") alloc] init]; NSLog(@"V %@", vector); Manager * manager = [[NSClassFromString(@"com.dental.Manager") alloc] init]; NSLog(@"M %@", manager); Phone * phone = [manager getPhone]; NSLog(@"P %@", phone); NSLog(@"O %@", [manager print: phone]); //[phone release]; //[manager release];
     
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status: Offline
Reply With Quote
Jan 29, 2004, 11:20 PM
 
OK, I may be able to answer this one myself. The release of the Manager and the Vector work fine, but I can't release the Phone object. I am inferring from that that any Java object I directly allocate needs to be released, but any object returned by the Java virtual machine must not be freed.

I still don't understand how things like autorelease pools, etc, work. Is release the equivalent of the C++ delete function?
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jan 29, 2004, 11:21 PM
 
I'm not exactly an expert on the Java bridge, but the [phone release] looks suspicious to me, since you didn't create or retain the phone.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status: Offline
Reply With Quote
Jan 29, 2004, 11:24 PM
 
Originally posted by Chuckit:
I'm not exactly an expert on the Java bridge, but the [phone release] looks suspicious to me, since you didn't create or retain the phone.
Thanks for the validation. I am still worried about memory leaks, so this is good to know.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:55 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2