Thursday, November 30, 2017
Java process consuming more memory than Xmx heap allocated
1. Behavior is the following:
Java has the following Xmx parameter set up for max heap size:
-Xmx24576m
2. Despite this a top command shows consumption bigger than that:
The above shows Resident Size (memory consumed by Java process) to be around 0.041 Terra = aprox 41 GB . This is far more than the allocated heap at step 1 - 24GB.
Note: Do not take into consideration the Virtual column, this memory is not the same with the one used by Java process.
3. If we do another test using command line, we get the same results:
ps aux | awk '{print $6/1024 " MB\t\t" $11 $12}' | sort -rn | head -n 1
It shows:
4. Our matter is confirmed, something else is getting memory space being occupied.
Additional pmap can be used to confirm our doubts - just to get memory consumed by anonymous block allocations:
pmap -x 4366 | grep anon | awk '{s+=$3} END {s=s/1048576 "MB";print s}'
5. One possible resolution to this (there are many solutions found over the Internet) is to tune glibc. It is known on Linux to have those kind of memory leaks.
Especially the parameter MALLOC_ARENA_MAX needs to be tuned, and a value of 2 is highly recommended:
export MALLOC_ARENA_MAX=2
More details about this variable here - a very good article to read:
https://siddhesh.in/posts/malloc-per-thread-arenas-in-glibc.html
Monday, November 27, 2017
Install Apache Maven
1. This assumes you already have Java 7+ already up and running:
java -version
2. Download latest Apache Maven package from https://maven.apache.org/download.cgi
and move it to /usr/local folder.
Alternatively you can download directly on your linux instance using wget:
wget http://www-eu.apache.org/dist/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
3. Untar the zip:
sudo tar xzf apache-maven-3.5.2-bin.tar.gz
4. It is by default extracted to an apache-maven-3.5.2 folder. For ease, can create a symbolic link for maven:
ln -s apache-maven-3.5.2 maven
5. Get proper path in place:
export PATH=/usr/local/maven/bin:${PATH}
6. Test by checking maven installed version:
mvn -version
7. To make it work, it also needs a settings.xml file. This file needs to be under /home/user/.m2 folder and can have following sections:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/user/local/.m2/repository</localRepository><interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
<pluginGroups>
</pluginGroups>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
8. If you have an already existing project, you can test from within project folder the following command - it shall build succesfully and download any dependency to the repository:
mvn clean install -s /home/user/.m2/settings.xml
java -version
2. Download latest Apache Maven package from https://maven.apache.org/download.cgi
and move it to /usr/local folder.
Alternatively you can download directly on your linux instance using wget:
wget http://www-eu.apache.org/dist/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
3. Untar the zip:
sudo tar xzf apache-maven-3.5.2-bin.tar.gz
4. It is by default extracted to an apache-maven-3.5.2 folder. For ease, can create a symbolic link for maven:
ln -s apache-maven-3.5.2 maven
5. Get proper path in place:
export PATH=/usr/local/maven/bin:${PATH}
6. Test by checking maven installed version:
mvn -version
7. To make it work, it also needs a settings.xml file. This file needs to be under /home/user/.m2 folder and can have following sections:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/user/local/.m2/repository</localRepository><interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
<pluginGroups>
</pluginGroups>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
8. If you have an already existing project, you can test from within project folder the following command - it shall build succesfully and download any dependency to the repository:
mvn clean install -s /home/user/.m2/settings.xml
Subscribe to:
Posts (Atom)