<-- Back

OutOfMemoryError: unable to create native thread - resolving errors caused by native thread exhaustion

Introduction

When too many concurrent threads are in use and the limit is reached, the following out-of-memory log can be thrown:

java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

When this happens, the application will not be able to create additional threads to handle new incoming requests, resulting in a loss of functionality.

Environment

Applications hosted in Mendix Cloud

Cause

This error can occur when an application has exhausted the limit of native threads allowed by the operating system. Analysis of Java Virtual Machine (JVM) metrics may show that the total number of threads has been steadily increasing. For example, this can indicate that a custom Java action in the application is not properly closing native threads, causing thread leakage over time until the system limit is reached.

{B6220BEB-39FD-4D1F-A630-0FCDA9F02D5F}.png

Solution / Workaround

Restarting the application temporarily resolves the issue by resetting the thread count. However, to prevent recurrence, investigate custom Java actions to ensure threads are correctly closed.

  1. Monitor the JVM metrics (specifically Total number of threads in the JVM process), to identify if the thread count increases continuously without releasing.
  2. Review custom Java actions for thread-handling logic. Ensure that every thread created is explicitly closed or terminated after use. If the issue is confirmed in custom code, refactor the implementation to avoid leaving threads open.

Note that Mendix Support cannot assist with troubleshooting Java Actions. This is outside of our scope, as outlined in our documentation: What We Expect from You.

Internal information related

  • 250979
  • C3T260XGA/p1749036575086689

Additional information

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.