[WooreeINFO] (STM32F746G-DISCO) Exception regarding to the number of threads in Java

Dear MicroEJ,

We’ve met an exception while trying to run our DLMS application in your ‘reference’ on top of STM32F746G-DISCO; which was about the number of threads in Java.

We guess the current limit on the number of threads in Java might be around 20, however i think we need more. And here are my questions as:

(1) Based on your reference on top of STM32F746G-DISCO, what is the maximum number of threads we can use for our application?

(2) Do you think we can increase this limit to about 40 or above - without any modification of your reference firmware (RTOS + Java VM)?

(3) Is there any way to manage the java threads on purpose, such as to kill some threads at any time?

i’d like to appreciate you for the feedback in advance.

Regards
YH Kwon

Any update on this thread yet from MicroEJ?

Hi @kwonyh,

For standalone application the maximum number of thread is defined in the Launch Configuration (Tab configuration → Memory). Assuming you have enough RAM memory, the theoretical maximum is 255.

When building a kernel of a multi-application firmware you can define the total maximum of thread as well as the maximum number of thread per feature.

When building a Sandboxed application you have no way of modifying this value

For our reference implementation we have restricted to 20 thread per feature (34 in total), modifying this value require to rebuild a Kernel.

When stopping a feature all the associated Thread will be killed, so you can split your applications in multiple features and start/stop them when needed.

Regards

Dear Pierre Rivron,

Thank you so much for the detailed information first of all, however there might be some of discrepancy between your description and our trial.

When our engineer has tried to build our DLMS application as a sandboxed one so as to run it in your reference firmware, on top of the STM32F746G-DISCO hardware, he sees the following exception as:

Exception in thread "ej.wadapps.app.default" com.is2t.vm.support.InternalLimitsError: Too many alive java threads (21)
at java.lang.System.@M:0x803ecd8:0x803ece8@
at java.lang.Throwable.@M:0x804c42c:0x804c442@
at java.lang.Throwable.@M:0x8052560:0x8052583@
at java.lang.Error.@M:0x804d754:0x804d766@
at java.lang.VirtualMachineError.@M:0x804af9c:0x804afae@
at com.is2t.vm.support.InternalLimitsError.@M:0x8042850:0x8042862@
at java.lang.Thread.@M:0x8059de0:0x8059e4e@
at java.util.Timer.@M:0x8053e28:0x8053e69@
at org.eclipse.californium.core.network.stack.BlockwiseLayer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03bb050:0xc03bb0b6@
at org.eclipse.californium.core.network.stack.CoapStack.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03c2680:0xc03c2714@
at org.eclipse.californium.core.network.CoapEndpoint.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03c82ac:0xc03c8324@
at org.eclipse.californium.core.network.CoapEndpoint.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03ccd78:0xc03ccd96@
at org.eclipse.californium.core.network.CoapEndpoint.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03d3670:0xc03d368a@
at wooree.dlms.agent.common.coap.CustomCoapServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03b4688:0xc03b46c4@
at wooree.dlms.agent.common.coap.CustomCoapServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03bcb20:0xc03bcc3a@
at wooree.dlms.agent.common.coap.CustomCoapServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03c349c:0xc03c34b4@
at wooree.dlms.agent.AgentServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03c9600:0xc03c961c@
at wooree.dlms.agent.AgentServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03ce08c:0xc03ce0d2@
at com.wooree.TestActivity.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xc0381100@@M:0xc03d40ac:0xc03d40dc@
at Exception in thread "ej.wadapps.app.default" com/is2t/vm/support/InternalLimitsError: Too many alive java threads (21)
at java/lang/System.@M:0x0803ECD8:0x0803ECE8@
at java/lang/Throwable.@M:0x0804C42C:0x0804C442@
at java/lang/Throwable.@M:0x08052560:0x08052583@
at java/lang/Error.@M:0x0804D754:0x0804D766@
at java/lang/VirtualMachineError.@M:0x0804AF9C:0x0804AFAE@
at com/is2t/vm/support/InternalLimitsError.@M:0x08042850:0x08042862@
at java/lang/Thread.@M:0x08059DE0:0x08059E4E@
at java/util/Timer.@M:0x08053E28:0x08053E69@
at org/eclipse/californium/core/network/stack/BlockwiseLayer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03BB050:0xC03BB0B6@
at org/eclipse/californium/core/network/stack/CoapStack.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03C2680:0xC03C2714@
at org/eclipse/californium/core/network/CoapEndpoint.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03C82AC:0xC03C8324@
at org/eclipse/californium/core/network/CoapEndpoint.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03CCD78:0xC03CCD96@
at org/eclipse/californium/core/network/CoapEndpoint.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03D3670:0xC03D368A@
at wooree/dlms/agent/common/coap/CustomCoapServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03B4688:0xC03B46C4@
at wooree/dlms/agent/common/coap/CustomCoapServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03BCB20:0xC03BCC3A@
at wooree/dlms/agent/common/coap/CustomCoapServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03C349C:0xC03C34B4@
at wooree/dlms/agent/AgentServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03C9600:0xC03C961C@
at wooree/dlms/agent/AgentServer.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03CE08C:0xC03CE0D2@
at com/wooree/TestActivity.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03D40AC:0xC03D40DC@
at ej/wadapps/app/ActivityProxy.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x90003820:0x9000382D@
at com/microej/wadapps/management/util/ActivitiesSchedulerLowMemory.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x900045B0:0x90004836@
at ej/wadapps/management/ActivitiesSchedulerProxy.@F:100f38b461010000034f97b47211bf76675277b067ed40e9:0x9001B1E0@@M:0x9003E2D0:0x9003E2DE@
at ej/wadapps/browser/listener/application/ActivityDisplayServiceImpl.@F:100f38b461010000034f97b47211bf76675277b067ed40e9:0x9001B1E0@@M:0x9004A404:0x9004A46E@
at ej/wadapps/browser/listener/application/ActivityDisplayServiceImpl.@F:100f38b461010000034f97b47211bf76675277b067ed40e9:0x9001B1E0@@M:0x9004D46C:0x9004D47C@
at ej/observable/ObserverProxy.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x90004378:0x90004385@
at ej/observable/Observable.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x9000582C:0x9000585C@
at com/microej/wadapps/management/util/ActivitiesListImpl.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x900061E8:0x90006218@
at ej/wadapps/management/ActivitiesListProxy.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03CE22C:0xC03CE23A@
at __agentTest__/generated/AgentTestActivator.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03DB0C4:0xC03DB0F2@
at ej/components/registry/impl/AbstractRegistry.@M:0x08042E70:0x08042EC4@
at ej/components/registry/impl/AbstractRegistry.@M:0x08056E1C:0x08056E3E@
at ej/components/registry/util/BundleRegistryHelper.@M:0x08049368:0x08049382@
at __agentTest__/generated/AgentTestEntryPoint.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03DA354:0xC03DA37E@
at ej/kf/Kernel$2.@M:0x0802E43C:0x0802E478@
at java/lang/Thread.@M:0x08061278:0x08061290@
at java/lang/Thread.@M:0x080611C0:0x080611CC@
at java/lang/Thread.@M:0x08061230:0x0806123B@
com.microej.wadapps.management.util.activitiesschedulerlowmemory SEVERE: Error showing activity.
Exception in thread "main" java.lang.Error
at java.lang.System.@M:0x803ecd8:0x803ece8@
at java.lang.Throwable.@M:0x804c42c:0x804c442@
at java.lang.Throwable.@M:0x805084c:0x805086d@
at java.lang.Error.@M:0x804a740:0x804a750@
at ej.wadapps.app.ActivityProxy.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x90003820:0x90003854@
at com.microej.wadapps.management.util.ActivitiesSchedulerLowMemory.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x900045b0:0x90004836@
at Exception in thread "ej.wadapps.app.default" java/lang/Error
at java/lang/System.@M:0x0803ECD8:0x0803ECE8@
at java/lang/Throwable.@M:0x0804C42C:0x0804C442@
at java/lang/Throwable.@M:0x0805084C:0x0805086D@
at java/lang/Error.@M:0x0804A740:0x0804A750@
at ej/wadapps/app/ActivityProxy.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x90003820:0x90003854@
at com/microej/wadapps/management/util/ActivitiesSchedulerLowMemory.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x900045B0:0x90004836@
at ej/wadapps/management/ActivitiesSchedulerProxy.@F:100f38b461010000034f97b47211bf76675277b067ed40e9:0x9001B1E0@@M:0x9003E2D0:0x9003E2DE@
at ej/wadapps/browser/listener/application/ActivityDisplayServiceImpl.@F:100f38b461010000034f97b47211bf76675277b067ed40e9:0x9001B1E0@@M:0x9004A404:0x9004A46E@
at ej/wadapps/browser/listener/application/ActivityDisplayServiceImpl.@F:100f38b461010000034f97b47211bf76675277b067ed40e9:0x9001B1E0@@M:0x9004D46C:0x9004D47C@
at ej/observable/ObserverProxy.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x90004378:0x90004385@
at ej/observable/Observable.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x9000582C:0x9000585C@
at com/microej/wadapps/management/util/ActivitiesListImpl.@F:d9a737b46101000073783c876987b55b8e3aaa8e1d407fd1:0x90000000@@M:0x900061E8:0x90006218@
at ej/wadapps/management/ActivitiesListProxy.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03CE22C:0xC03CE23A@
at __agentTest__/generated/AgentTestActivator.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03DB0C4:0xC03DB0F2@
at ej/components/registry/impl/AbstractRegistry.@M:0x08042E70:0x08042EC4@
at ej/components/registry/impl/AbstractRegistry.@M:0x08056E1C:0x08056E3E@
at ej/components/registry/util/BundleRegistryHelper.@M:0x08049368:0x08049382@
at __agentTest__/generated/AgentTestEntryPoint.@F:5b0f7c456b010000d37548f1e20224d0b875cb968936fb41:0xC0381100@@M:0xC03DA354:0xC03DA37E@
at ej/kf/Kernel$2.@M:0x0802E43C:0x0802E478@
at java/lang/Thread.@M:0x08061278:0x08061290@
at java/lang/Thread.@M:0x080611C0:0x080611CC@

To rephrase the above, the 6th thread invokes such an exception upon its start; which is away from your description. If i understood correctly, we should be able to run up to 20 threads in our current application.

Please advise me further wherever we have any misunderstanding and/or we have mistaken.

Thanks again.
YH Kwon

Dear YH Kwon,

You may have reach the maximum amount of the whole system (34 threads for the Stm32F7 Blue firmware). Can you do an LLDump, to check the running threads. To do so press the user button on the board (the blue button).

Regards,

Dear Pierre Rivron,

i think we’ve been trying this with the ‘yellow’ firmware, however i’d like to make sure about this again with our software engineer tomorrow.

Per your webpage;

“blue” → Push apps with a smartphone (MicroEJ Developer - IoT Connectivity Solutions for Embedded Systems)
“yellow” → Download apps on-board (Get Started - App Development on STM32F746G-DISCO)

Thanks for your support once more.

Regards
YH Kwon

Dear Pierre Rivron,

i have just confirmed with our engineer that we’ve been with your ‘yellow’ firmware, and please find the trace messages in the console from the start up to the moment of pushing the blue button on the STM32F746G-DISCO hardware in the attachment.

Please advise me further wherever possible to have a resolution on this asap.

Thanks & Regards
YH Kwon
trace.jar (1.2 KB)

Dear YH Kwon,

The limitation on the Yellow firmware is lower than the blue one, can you try with the blue firmware ?
Can you do the LLDump when you reach the InternalLimitsError?

Regards,

Dear Pierre Rivron,

Thanks for your suggestion first of all, and our engineer has tried this already earlier today while i was in a meeting with Regis Latawiec in our office.

So he could have solved the problem of the ‘Number of Thread’ exception tentatively when he switched from ‘yellow’ to ‘blue’ firmware.

However he sees another problem with the timer event this time.

His DLMS application gets successfully a timer event for the first time after the device boots up, but there is no timer event ever after.

His expectation here is the periodic timer events arriving to retrieve the various measures from meters over the serial connection(RS-485).

He’s working on this resolution by himself first, and as he can get a summary of this problem so as to seek your help, i think i will post another topic here or send it to your technical support(support@microej.com).

Thanks & Regards
YH Kwon

Dear Pierre Rivron,

Based on our progress on this, we found that it’s not the problem of timer events. Our understanding is it’s linked to the CoAP library delivered lately from MicroEJ.

i have sent an email about this to Stephane.

Thanks
YH Kwon