Acknowledged

Critical Error for Monkey C Compiler with Mac OS Apple M Series and Java ARM64 JRE

I just set up Monkey C on the new MacBook Pro with the Apple M4 Pro chip (Nov 2024), which requires the ARM64 JRE version of Java.

The Monkey C installation verification was successful, but when I tried to run my app, I received a critical error referring to the Java CodeCache (see below).

When I run Build Current Project for the same device again, the error message is shorter. If I run it for a different device, I get the longer error message again.

It was also strange that I was prompted to select a debugger even though I selected "Run Without Debugging". The same error occurs with "Start Debugging".

The error message says to re-run the Monkey C Compiler with logging enabled, but I do not know how to do that.

This error is preventing me from running any code at all.

How can this be fixed?

Here's my setup:
Model: MacBook Pro 14 inch Nov 2024
Chip: Apple M4 Pro
OS: Sequoia 15.1.1

Here's what I did:

Download and install ConnectIQ SDK Manager
Download and install VS Code
Download and install Java ARM64 JRE (for Mac M series system)
Install Monkey C extension in VS Code
Run: Monkey C: Verify Installation - received message saying installation was verified
Run: Run Without Debugging - prompted to specify debugger (is this supposed to happen?)
Select Monkey C as debugger
Select device (arbitrary, e.g., vivoactive5)
Received error below:

Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
WARNING: vivoactive5: The launcher icon (30x30) isn't compatible with the specified launcher icon size of the device 'vivoactive5' (70x70). Image will be scaled to the target size.
ERROR: vivoactive5: A critical error has occurred. Please re-run the Monkey C Compiler with logging enabled and file a report with the Connect IQ support team.
CodeCache: size=131072Kb used=10901Kb max_used=10901Kb free=120170Kb
bounds [0x000000010a1f8000, 0x000000010acb8000, 0x00000001121f8000]
total_blobs=3357 nmethods=2858 adapters=412
compilation: disabled (not enough contiguous free space left)

* The terminal process terminated with exit code: 100.

Run: Monkey C: Build Current Project
Select vivoactive5 as device (same as before)
Received shorter error below:

WARNING: vivoactive5: The launcher icon (30x30) isn't compatible with the specified launcher icon size of the device 'vivoactive5' (70x70). Image will be scaled to the target size.
ERROR: vivoactive5: A critical error has occurred. Please re-run the Monkey C Compiler with logging enabled and file a report with the Connect IQ support team.

* The terminal process terminated with exit code: 100.

Run: Monkey C: Build Current Project
Select a different device
Received initial error again (except for newly selected device)

Parents
  • According to the java error message, you need to increase ReservedCodeCachesize [it's currently 128 MB].

    1) In VS Code, open the command palette [CMD-SHIFT-P] and select "Shell: Command: Install 'code' command in PATH" if you haven't done so already

    2) Open Terminal.app [if it's already open, open a new window]

    3) Type:

    code ~/.zshrc

    This will open the .zshrc file (located in your home folder) in vs code

    4) Add the following line to .zshrc

    export _JAVA_OPTIONS=-XX:ReservedCodeCacheSize=256m

    This will override ReservedCodeCacheSize to 256 MB (double the current size).

    5) Open your CIQ project in VS Code. (If it's already open, close the window and reopen it)

    6) Build the project. Ensure that the following line appears in the build output:

    Picked up _JAVA_OPTIONS: -XX:ReservedCodeCacheSize=256m

    Hopefully that will resolve your build issue. If not, try replacing 256m with a larger number.

    Another alternative would be to true a newer Java version. You didn't mention the distribution and version number of your JRE in the bug report. Personally I like to use https://adoptium.net/ [I usually use the recommended version on the front page.]

Comment
  • According to the java error message, you need to increase ReservedCodeCachesize [it's currently 128 MB].

    1) In VS Code, open the command palette [CMD-SHIFT-P] and select "Shell: Command: Install 'code' command in PATH" if you haven't done so already

    2) Open Terminal.app [if it's already open, open a new window]

    3) Type:

    code ~/.zshrc

    This will open the .zshrc file (located in your home folder) in vs code

    4) Add the following line to .zshrc

    export _JAVA_OPTIONS=-XX:ReservedCodeCacheSize=256m

    This will override ReservedCodeCacheSize to 256 MB (double the current size).

    5) Open your CIQ project in VS Code. (If it's already open, close the window and reopen it)

    6) Build the project. Ensure that the following line appears in the build output:

    Picked up _JAVA_OPTIONS: -XX:ReservedCodeCacheSize=256m

    Hopefully that will resolve your build issue. If not, try replacing 256m with a larger number.

    Another alternative would be to true a newer Java version. You didn't mention the distribution and version number of your JRE in the bug report. Personally I like to use https://adoptium.net/ [I usually use the recommended version on the front page.]

Children
  • Thank you! But it still does not work. Below is the error message I get after increasing to 256 MB. It says it's full, but there is a lot of free cache left. (The numbers are different probably because I built the project for a different device so the full error message would show up. Otherwise it shows an abbreviated error message with less details.)

    Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
    Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
    WARNING: venu2: The launcher icon (30x30) isn't compatible with the specified launcher icon size of the device 'venu2' (70x70). Image will be scaled to the target size.
    ERROR: venu2: A critical error has occurred. Please re-run the Monkey C Compiler with logging enabled and file a report with the Connect IQ support team.
    CodeCache: size=262144Kb used=13592Kb max_used=13592Kb free=248551Kb
                                                                         bounds [0x000000010a9f8000, 0x000000010b758000, 0x000000011a9f8000]
                                                                                                                                             total_blobs=3768 nmethods=3242 adapters=440
                                                                                                                                                                                         compilation: disabled (not enough contiguous free space left)
    
     *  The terminal process terminated with exit code: 100.

    I installed jre-8u431-macosx-aarch64.dmg from the link on the main java downloads page: https://www.java.com/en/download/

    I actually tried installing the Intel version first, and after the Monkey C verification failed, I uninstalled it and installed the ARM64 java version above. The java installation prompts appeared to work, so I assume it is installed correctly. (And I proceeded to uninstall the Monkey C extension and re-install it.)

    Any other ideas?

  • This comment was deleted.