 |
 |
Releasing objects obtained from Java
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|