faq On Linux how do I fix java.lang.OutOfMemoryError unable to create new native Thread
This error occurs when your Java app is trying to creating more threads than it is allowed by the OS. In Linux, both a process and a thread are handled in the same way such that limits on processes indirectly reflect limits on threads.
Take a look at the following kernel parameters. You will need to increase their values based on your requirements.
cat /proc/sys/kernel/threads-max
cat /proc/sys/kernel/pid_max
cat /proc/sys/vm/max_map_count
The following examples show how to set their values.
# Set temporarily - max of 100k threads executable by kernel
echo 100000 > /proc/sys/kernel/threads-max
# Set permanently - max of 100k threads executable by kernel
sysctl -w kernel.threads-max=100000 >> /etc/sysctl.conf
# Max of 400k processes simutaneously executable by kernel
echo 400000 > /proc/sys/kernel/pid_max
# Max of 500k Virtual Memory Areas (VMAs) owned by a process
echo 500000 > /proc/sys/vm/max_map_count
Add user limits in /etc/security/limits.conf
. The following example sets both hard (absolute) and soft (warning) limits for the number of processes and number of open files for the user, foo
.
vi /etc/security/limits.conf
foo hard nproc 50000
foo soft nproc 50000
foo hard nofile 60000
foo soft nofile 60000
You can use ulimit
to view the user limits.
# View all user limits
ulimit -a
# View user processes
ulimit -u
Finally, if your Java app is launched by systemd
, then check to see if UserTasksMax
is set to a low value. It specifes the TasksMax
setting for all users and determines the thread limit.
Set or comment out UserTasksMask
in /etc/systemd/system.conf
:
vi /etc/systemd/system.conf
...
UserTasksMax=60000
...
PadoGrid Manual
Overview
- Home
- PadoGrid in 5 Minutes
- Quick Start
- Introduction
- Bundle Catalogs
- Building PadoGrid
- Supported Data Grid Products and Downloads
- PadoGrid Components
- Installing PadoGrid
- Root Workspaces Environments (RWEs)
- Initializing PadoGrid
- Bash Auto-Completion
- Viewing PadoGrid Summaries
- Updating Products
- Upgrading PadoGrid
- Migrating Workspaces
- PadoGrid Pods
- Kubernetes
- Docker
- Apps
- Software List
Operations
- Workspace Lifecycle Management
- Creating RWE
- Creating Workspace and Starting Cluster
- Managing Workspaces
- Understanding Workspaces
- Understanding Clusters
- Running Clusters
- Default Port Numbers
- Running Clusters Independent of PadoGrid
- Running Apps
- Understanding Groups
- Running Groups
- Understanding Bundles
- User Bundle Repos
- Using Bundle Templates
- Bundle Repo Guidelines
- User Bundle Catalogs
- Private Bundle Repos
- Gitea Repos
- Running Bundles in Container
- PadoGrid Addon Jars
- Understanding PadoGrid Pods
- Tested Vagrant Boxes
- VM-Enabled Pods
- Multitenancy
- Multitenancy Best Practices
- PadoGrid Configuration Files
Tools
Platforms
Clouds
Pado
Geode/GemFire
- Geode CLASSPATH
- Geode Kubernetes
- Geode Minikube
- Geode Minikube on WSL
- Geode Docker Compose
- Geode Grafana App
- Geode
perf_test
App - Geode WAN Example
- Geode Workspaces on VMs
- Geode on AWS EC2
- Reactivating Geode Workspaces on AWS EC2
Hazelcast/Jet
- Hazelcast CLASSPATH
- Creating Jet Workspace
- Configuring Hazelcast Addon
- HQL Query
- Hazelcast Kubernetes
- Hazelcast GKE
- Hazelcast Minikube
- Hazelcast Minikube on WSL
- Hazelcast Minishift/CDK
- Hazelcast OpenShift
- Hazelcast Docker Compose
- Hazelcast Desktop App
- Hazelcast Grafana App
- Hazelcast
jet_demo
App - Hazelcast
perf_test
App - Hazelcast WAN Example
- Hazelcast Workspaces on VMs
- Hazelcast on AWS EC2
- Reactivating Hazelcast Workspaces on AWS EC2
ComputeDB/SnappyData
Coherence
Hadoop
Kafka/Confluent
Mosquitto
- Mosquitto CLASSPATH
- Mosquitto Overview
- Installing/Building Mosquitto
- Clustering MQTT
- Cluster Archetypes
- Enabling Mosquitto SSL/TLS
- Mosquitto Docker Compose
- MQTT perf_test App
Redis
Spark