开发者

Free heap size does not increase in Maven

When I run maven-jetty-plugin, I run next command:

mvn -DMAVEN_OPTS="-Xmx1024m -Xms512m" -Djetty.port=8080 jetty:run

but when I try to output fre开发者_C百科e heap size with

Long heapFreeSize = Runtime.getRuntime().freeMemory();

It always outputs something about about 30000000.

I suppose it's size in bytes, so about 30 megabytes.

Why then free heap memory did not increase?


MAVEN_OPTS is an environment variable, which is read by Maven and used as the command line arguments for forking java processes. Command line arguments control how the Java executable is started, e.g. stuff like memory settings.

-D is used for setting Java System Properties, which is something completely different than command line arguments. Java System Properties can be read programmatically, e.g. by using System.getProperties().

Windows:

SET MAVEN_OPTS="-Xmx1024m -Xms512m"
mvn -Djetty.port=8080 jetty:run

Linux:

export MAVEN_OPTS="-Xmx1024m -Xms512m"
mvn -Djetty.port=8080 jetty:run


I think -DMAVEN_OPTS="-Xmx1024m -Xms512m" is not correct way to specify memory params here.

Set a env variable called MAVEN_OPTS with content "-Xmx1024m -Xms512m"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜