Increasing heap size with vertx run command

749 views
Skip to first unread message

Arik Bron

unread,
Nov 16, 2017, 7:54:54 AM11/16/17
to vert.x
Hi gents,

We're running on Vert.x 3.4.1.

According to vertx run command help, it doesn't support an increase of heap size like java launcher does.

In case I'm missing something, is it possible to increase the default heap size allocated by vertx run command without switching to running vertx application with java and fat jars?

Thanks,
Arik

Julien Viet

unread,
Nov 16, 2017, 10:21:59 AM11/16/17
to vert.x
you can set the JAVA_OPTS env variable where you define these settings.

Julien

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/e5b1ff6a-9665-4f68-a8e2-800aca420f8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arik Bron

unread,
Nov 16, 2017, 10:55:59 AM11/16/17
to vert.x
Thanks Julien,

So basically before calling vertx run, I can use the following?

JAVA_OPTS='-Xms1024m -Xmx2048m'

Arik Bron

unread,
Dec 1, 2017, 8:01:38 PM12/1/17
to vert.x
Hi guys,

We tried everything, and by everything I mean the following configuration commands prior executing vertx run

export JAVA_OPTS="-Xms3072m -Xmx4096m"
export _JAVA_OPTIONS="-Xms3072m -Xmx4096m"
export JAVA_OPTIONS="-Xms3072m -Xmx4096m"
JAVA_OPTS="-Xms3072m -Xmx4096m"
_JAVA_OPTIONS="-Xms3072m -Xmx4096m"
JAVA_OPTIONS="-Xms3072m -Xmx4096m"

Although _JAVA_OPTIONS is the correct name, we tried variations mentioned above. Nothing helps - JVM launches with the same max heap size of 1851785216

Anyone among you addressed this problem before?

Clement Escoffier

unread,
Dec 2, 2017, 4:17:35 AM12/2/17
to ve...@googlegroups.com
Hello Arik,

Do you mean the `vertx` command line tool? If this is the case, the right variables are:

* JVM_OPTS
* JAVA_OPTS
* VERTX_OPTS

These three are added to the command line: java -jar ${JVM_OPTS} ${JAVA_OPTS} ${VERTX_OPTS} ….. 



Regards,

Clement

Arkady Bron

unread,
Dec 2, 2017, 5:59:55 AM12/2/17
to ve...@googlegroups.com
Thank you Clement.

I went directly into the vertx script and tried adding the following:
JAVA_OPTS="-Xms3072m -Xmx4096m"

This didn't help - the command
java -XX:+PrintFlagsFinal -version | grep HeapSize

continues to show
uintx MaxHeapSize                              := 1851785216

I tried extending the default value of JVM_OPTS to the following one:
JVM_OPTS="-XX:+UseBiasedLocking -XX:BiasedLockingStartupDelay=0 -Xms3072m -Xmx4096m"

This didn't help either.

Was the support of JAVA_OPTS and JVM_OPTS tested? What am I doing wrong here while trying to increase the maximum jvm heap size???

Clement

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/_FpwNweCXz8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.

Clement Escoffier

unread,
Dec 2, 2017, 1:32:07 PM12/2/17
to ve...@googlegroups.com

On 2 Dec 2017, at 11:59, Arkady Bron <arkad...@gmail.com> wrote:

Thank you Clement.

I went directly into the vertx script and tried adding the following:
JAVA_OPTS="-Xms3072m -Xmx4096m"

This didn't help - the command
java -XX:+PrintFlagsFinal -version | grep HeapSize

continues to show
uintx MaxHeapSize                              := 1851785216

I tried extending the default value of JVM_OPTS to the following one:
JVM_OPTS="-XX:+UseBiasedLocking -XX:BiasedLockingStartupDelay=0 -Xms3072m -Xmx4096m"

This didn't help either.

Was the support of JAVA_OPTS and JVM_OPTS tested? What am I doing wrong here while trying to increase the maximum jvm heap size???

Yes it was tested. I just checked and for me it works:

export JAVA_OPTS="-Xms3072m -Xmx4096m -XX:+PrintFlagsFinal"
bin/vertx version

It displays all the flag including:
    uintx MaxHeapSize                              := 4294967296                          {product}

If I change the values, I get a different heap size, for example with 2048m, I got:

    uintx MaxHeapSize                              := 2147483648                          {product}

So, you will have to tell us more how you configure and run your application.

Clement

Alexander Lehmann

unread,
Dec 2, 2017, 1:55:06 PM12/2/17
to vert.x
I think you may be checking the settings the wrong way, the java command does not accept settings from JAVA_OPTS or JVM_OPTS, this is a convention adopted by almost any java program that has its own start script.

If you run a vertx program that just waits for some time, you should see the command arguments with jps


25968 Launcher -XX:+UseBiasedLocking -XX:BiasedLockingStartupDelay=0 -Xmx1999m -Dvertx.cli.usage.prefix=vertx -Djava.util.logging.config.file=c:\Javatools\vertx\vert.x-3.5.0\bin\..\conf\logging.properties -Dvertx.home=c:\Javatools\vertx\vert.x-3.5.0\bin\.. -Dvertx.clusterManagerFactory=io.vertx.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory
Clement

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/_FpwNweCXz8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.

Arkady Bron

unread,
Dec 3, 2017, 11:09:46 AM12/3/17
to ve...@googlegroups.com
Hi,

Our launch script is very simple and this is how it looks:

JAVA_OPTS="-Xms2048m -Xmx4096m"
vertx/bin/vertx run src/com/whildey/adserver/vertx/MainVerticle.java -cp classes -conf conf/my-conf.json -cluster &
service nginx restart

When we run it we see that JVM is launched properly with -Xms and -Xmx setting, so I guess there is no issue with vertx script.

Yet, when we check the max heap size setting with the following command, we see a constant value mentioned before (1851785216==1766MB):
java -XX:+PrintFlagsFinal -version | grep HeapSize

If you think that this is not the right way to check the max heap size, could you please write in the followup response the full command that we need to use?

Kind regards,
Arik


Jez P

unread,
Dec 3, 2017, 11:18:06 AM12/3/17
to vert.x
That's not going to tell you the heap size in the vertx-triggered java process, only the default heap size of a newly spawned java process. 

As Alex says use jps, which will show you the command line actually used to trigger the java process you wish to examine. Alternatively connect something like VisualVM to the running process and examine its parameters directly. 

Alexander Lehmann

unread,
Dec 3, 2017, 12:16:26 PM12/3/17
to vert.x
the environment is not propagated to the next commands when it is set in a shell script or as a prefix of the command plus the java command does not evaluate the JAVA_OPTS environment variable

to verify that JAVA_OPTS is passed to vertx, using ps is really the simplest way, to check that the JAVA_OPTS are evaluated, you need a shell script like this (but that is kind of pointless as this doesn't check the vertx script).

#! /bin/sh
JAVA_OPTS
="-Xms2048m -Xmx4096m"
java $
{JAVA_OPTS} -XX:+PrintFlagsFinal -version | grep HeapSize


this should print the value that you expect.
Reply all
Reply to author
Forward
0 new messages