Problems with [NSAutoreleasePool release]

I ran the MOE application in iOS simulator but the app was suddenly closed with the following message.

2016-09-13 21:54:53.234 ios-moe[5079:1272350] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-13 21:54:53.235 ios-moe[5079:1272350] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-13 21:54:53.235 ios-moe[5079:1272350] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-13 21:54:53.236 ios-moe[5079:1272350] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-13 21:54:53.237 ios-moe[5079:1272350] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).

Could someone tell me what does the message mean?

I slightly changes the iOSMOELauncher.java by reference to libGDX wiki as follows.
https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx

public class IOSMoeLauncher extends IOSApplication.Delegate implements IActivityRequestHandler{

private IOSApplication iosApplication;
protected IOSMoeLauncher(Pointer peer) {
    super(peer);
}
@Override
protected IOSApplication createApplication() {
    final IOSApplicationConfiguration config = new IOSApplicationConfiguration();
    config.orientationLandscape = false;
    config.orientationPortrait = true;
    config.useAccelerometer = false;
    iosApplication = new IOSApplication(new Memorenger(this), config);
    return iosApplication;
    }
public static void main(String[] argv) {
    NSAutoreleasePool pool = NSAutoreleasePool.alloc();
    UIKit.UIApplicationMain(0, null, null, IOSMoeLauncher.class.getName());
    pool.dealloc();
}
@Override
public void showAds(boolean show) {
}
@Override
public void openURL(String url) {
}

}

Dear keybow007,

with MOE you do not need to put UIKit.UIApplicationMain... in an autoreleasepool, the main method is already in one. However if you really need to use autorelease pools, you should use NatJ-s API:

ObjCRuntime.autoreleasepool(() -> {
	// Do stuff
});

// OR

final long autoreleasePool = ObjCRuntime.createAutoreleasePool();
try {
	// Do stuff
} finally {
	ObjCRuntime.releaseAutoreleasePool(autoreleasePool);
}

Dear Kristóf

Thanks for your reply.

However I’m afraid I don’t really understand what you said because I’m not familiar with iOS .

“with MOE you do not need to put UIKit.UIApplicationMain… in an autoreleasepool” means do I need to make any change in the main method (getting rid of UIKit.UIApplicationMain… etc)?

I slightly changed the “protected IOSApplication createApplication()” but I didn’t do anything about the main method.

I’d appreciated if you would give me more details about your suggestion.

Thank you so much for your help.

Dear keybow007,

to put it simply, remove NSAutoreleasePool pool... and related operations, so you get this:

public static void main(String[] argv) {
    UIKit.UIApplicationMain(0, null, null, IOSMoeLauncher.class.getName());
}

MOE automatically does the autoreleasepool wrapping for you when calling the application’s main function.

Dear Kristóf

Thanks for your reply.

However, removing “NSAutoreleasePool pool…” and related operations as you suggested didn’t work for my case.

Should I really remove “NSAutoreleasePool pool…” because I found the part in the original IOSMoeLauncher.java. ?

Dear keybow007,

yes, in case of the static void main(String[] argv) {...} method, wrapping the UIKit.UIApplicationMain(...) call in an autoreleasepool is unnecessary.
Is the output exactly the same as before? If yes, please delete the build directory and run again. If the output is still the same, could you please copy a bigger chunk of the output here?

Dear Kristóf

Thanks for your reply.

I did remove the “NSAutoreleasePool” part and delete the ‘build’ directory and ran again but the output is still the same.

The following is the copy of the full message in ‘Run’ window.

/Users/telulullc/AndroidStudioProjects/MemorangerGDXmoeJP/gradlew moeLaunch -Pmoe.launcher.options=no-build,config:Debug -Pmoe.launcher.simulators=AB727577-CCAC-45C2-B030-CC3991CBCEC3
Configuration on demand is an incubating feature.
:ios-moe:moeLaunchart I 3174 259202 /Volumes/SSD/gh-moe-master/aosp/art/runtime/parsed_options.cc:449] setting boot class path to /Users/telulullc/Library/Developer/CoreSimulator/Devices/AB727577-CCAC-45C2-B030-CC3991CBCEC3/data/Containers/Bundle/Application/32E8BD43-424F-40F6-8C9E-9AC687AB0048/ios-moe.app/application.jar:/Users/telulullc/Library/Developer/CoreSimulator/Devices/AB727577-CCAC-45C2-B030-CC3991CBCEC3/data/Containers/Bundle/Application/32E8BD43-424F-40F6-8C9E-9AC687AB0048/ios-moe.app
art W 3174 259202 /Volumes/SSD/gh-moe-master/aosp/art/runtime/native/java_lang_Runtime.cc:65] android_update_LD_LIBRARY_PATH not found; .so dependencies will not work!
art W 3174 259202 /Volumes/SSD/gh-moe-master/aosp/art/runtime/native/java_lang_Runtime.cc:65] android_update_LD_LIBRARY_PATH not found; .so dependencies will not work!
2016-09-14 22:03:49.684 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.685 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.686 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.687 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.688 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.689 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.693 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.694 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.695 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.695 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.696 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.696 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.697 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.697 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.697 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.698 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.698 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.699 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.699 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.699 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.700 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.700 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.700 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.701 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.701 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.702 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.703 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.704 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.704 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.704 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.705 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.705 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.706 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.706 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.707 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been drained, do not release it (double release).
2016-09-14 22:03:49.707 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
2016-09-14 22:03:49.708 ios-moe[3174:259265] *** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).

IOSApplication 3 iOS version: 9.3
IOSApplication 3 scale: 2.0
IOSApplication 3 Status bar is visible (height = 20.0)
IOSApplication 3 Total computed bounds are w=640.0 h=920.0
IOSGraphics 3 Display: ppi=163, density=2.0
IOSApplication 3 created
IOSApplication 3 resumed
IOSApplication 3 Status bar is visible (height = 20.0)
IOSApplication 3 Total computed bounds are w=640.0 h=920.0

BUILD SUCCESSFUL

Total time: 32.957 secs

Thanks for your help.

Dear keybow007,

is it possible to share your project privately with us?

Dear Kristóf

Sure it is. Please tell me how to send the project to you (The zipped project size is 386MB).

Thanks