B4J Question Java VPS problem

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Hi,
I have a B4J server app compiled with Open JDK 14.

I want to install this app on a VPS, so I followed the steps here: https://www.b4x.com/android/forum/threads/server-run-a-server-on-a-vps.60378/

This links to the post here which suggests that I would need to download the OPEN JDK from this link https://b4xfiles-4c17.kxcdn.com/b4j/linux_jdk-14.0.1.zip

I uploaded and extracted these files,
I uploaded the compiled jar, (F5 in release mode)

The server starts up ok, but when I try to communicate with it I get the following error:

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 24 bytes for AllocateHeap
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Unscaled Compressed Oops mode in which the Java heap is
# placed in the first 4GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 4GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (allocation.cpp:46), pid=23747, tid=23770
#
# JRE version: OpenJDK Runtime Environment (11.0.1+13) (build 11.0.1+13)
# Java VM: OpenJDK 64-Bit Server VM (11.0.1+13, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

--------------- S U M M A R Y ------------

Command Line: myB4JServer.jar

Host: x86_64, 4 cores, 5G, x86_64
Time: Mon Aug 1 07:46:05 2022 UTC elapsed time: 112 seconds (0d 0h 1m 52s)

Any idea what I should do to resolve this.

Note: the server works perfectly on a local Windows machine.

BTW, I have run the program on OPENJDK 14 and OPENJDK 11 runtime with the same results.
 

aeric

Expert
Licensed User
Longtime User
In your writing you mentioned you compiled the jar in OpenJDK 14 but the error logs show the server is using OpenJDK 11. Is it incompatibility?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
When I Google search the problem it points me to memory overcommit or dynamic memory settings in the VM. Is there any option to disable or enable this setting?
 
Upvote 0

teddybear

Active Member
Licensed User
When I Google search the problem it points me to memory overcommit or dynamic memory settings in the VM. Is there any option to disable or enable this setting?
As aeric said, check the value of vm.overcommit_memory
#sysctl vm.overcommit_memory
if it is 2, change it into 0.
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Thanks for the tip, where would I find this setting in the VPS setting or is it in an ini file somewhere for Java or can I put it on the commandline?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
You didn't mention what OS the VPS is running. Try search how to change the setting for that OS.
 
Upvote 0

Tecuma

Member
Licensed User
I assume you have Linux running as OS in your VPS.
Here are some information for memory overcommitment in a Linux OS.
If available you can run free command to see the actual state of memory in your VPS.
What you also may check with the provider of the VPS is the host running the VPS. The host may have a state (VMs configuration and host configuration) where it is already at its limits.
 
Upvote 0
Top