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)

  • Sorry, I should’ve made it clear that compiler options should be set in the Monkey C extension settings, in VS Code. There’s no need to run any compiler commands manually.

    - Open command palette (CMD-SHIFT-P)

    - In the command palette, search for “User Settings” and select it

    - In the user settings, search for “Monkey C”. This will open the Monkey C extension settings

    - In the Monkey C extension settings, modify the compiler options setting as necessary. It should be set to nothing (i.e. a blank string) by default.

    Don’t forget to change the compiler options setting back to a blank string when you’re done.

  • Thanks! But I am not very well versed with command line entry; so far I have only been running via VS Code. In the Mac OS Terminal, I successfully changed the PATH and verified that the monkeyc version was recognized. But if I try to copy and paste the compiler command from the VS Code terminal into the Mac OS Terminal, I get "<quote>" in place of output, and I don't know how to get proper output.

  • Still no luck.

    I uninstalled Java according to their instructions: https://www.java.com/en/download/help/mac_uninstall_java.html.

    Then I installed the Temurin aarch64 JRE: https://adoptium.net/temurin/releases/?os=mac

    Then I uninstalled and re-installed the Monkey C extension in VS Code.

    Now I'm only getting the abbreviated error and not the full error message. So I don't know for certain if it's the same error, but I assume it is.

    I bumped up the cache to 1024m, and it didn't help.

    The error says to "re-run the Monkey C compiler with logging enabled". How do I do that?

    Picked up _JAVA_OPTIONS: -XX:ReservedCodeCacheSize=1024m
    WARNING: d2air: The launcher icon (30x30) isn't compatible with the specified launcher icon size of the device 'd2air' (60x60). Image will be scaled to the target size.
    ERROR: d2air: 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.

  • > 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

    Yes but it also says:

    > compilation: disabled (not enough contiguous free space left)

    So it could be that the compiler is failing to allocate a huge amount of memory (larger than the largest contiguous block in either your original case or with the increase to 256 MB).

    I would try either:

    - continuously increasing the cache size until works (e.g. try 1024m)

    or

    - uninstalling your jre and using a jre from https://adoptium.net/ (like the default one that it offers you on the front page - this is typically autodetected as the latest LTS jre for your OS/architecture)

    In the past I have had memory issues when exporting CIQ projects. Not the same thing, of course, as there's multiple builds in that case, and it seems that the memory usage is much higher. But it does show that sometimes the default java settings need to be tweaked to get java to work.

    To get around my memory issues, I had to use -Xmx4g. (Again, I don't think this necessarily applies in your situation, and I haven't had the same problem with the code cache size as you. However, I have seen stackoverflow posts about how newer jres require larger code caches, and how they have a larger default code cache size.)