This project demonstrates the memory leak of Avatica's DriverVersion.load
- Run
mvn package
- Upload target/calcite-avatica-driver-version-test-0.1-SNAPSHOT-bin.zip to a Linux CentOS 6.9 machine
- Unzip the zip to a folder, cd the folder
- Run the
./run.sh
. - Then using the jeprof util to monitor the heap by following steps(Verified on Centos 6.9, should work on most Linux-es)
wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2
tar xvf jemalloc-5.1.0.tar.bz2
cd jemalloc-5.1.0
./configure --enable-prof --prefix=/usr/local
make
sudo make install
- Add
export MALLOC_CONF="prof:true,lg_prof_sample:1,lg_prof_interval:26,prof_prefix:/{YOUR INTENDED FOLDER}/jeprof.out"
to run.sh - Add
LD_PRELOAD="/usr/local/lib/libjemalloc.so"
before thenohup java
in run.sh - Execute the run.sh to start the test Java main class
- If in non-GUI Linux, goto the
/{YOUR INTENDED FOLDER}/
, and runjeprof --show_bytes --dot `which java` jeprof.out.xxxx.heap > avatica_leak_test.dot
,jeprof.out.xxxx.heap
is the latest heap file generated by jemalloc. - Pull the
avatica_leak_test.dot
to local folder {$somepath}, download graphviz(https://www.graphviz.org/download/), and then rundot -Tpng {$somepath}/avatica_leak_test.dot -o {$somepath}/avatica_leak_test.png
- More info, can visit https://github.com/jeffgriffith/native-jvm-leaks to learn more