2

I am running a java program under Valgrind to check memory leaks in 32 bit Red hat Linux. While i execute the program using valgrind, JVM is not starting up throwing the below exception.

Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

My environment is

Red Hat Enterprise Linux Server release 6.2 (Santiago)

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)

valgrind-3.6.0

I was able to run the same program without Valgrind successfully.The command used is

valgrind  -v --smc-check=all --tool=memcheck --leak-check=yes --show-reachable=yes --leak-check=full --freelist-vol=100000000 --log-file=log.txt java -d32 -classpath "./bin:./lib/*" -Djava.library.path=/home/jni test.TestMain

Am I missing any thing here?

srvnn
  • 75
  • 1
  • 7
  • Java used garbage collection, why do you want to check for memory leaks? Memory leaks where? – Elliott Frisch Dec 20 '13 at 05:46
  • My program involves JNI integration which has to be tested for memory leaks. But the issue seems to be JVM startup with Valgrind with a simple java program. I am not sure is this a bug already? – srvnn Dec 20 '13 at 06:07
  • Can you try adding `-Xms1024m -Xmx1024m` after `java` on your command line? – Elliott Frisch Dec 20 '13 at 06:29
  • @JosefN I know that it cannot, but using valgrind on Java code would be a mistake ... (there *are* java profilers). – Elliott Frisch Dec 20 '13 at 06:30
  • Hi Elliott, I tried setting the heap memory size but the result is same, though there are enough memory available in the machine. # free -m total used free shared buffers cached Mem: 15101 1905 13195 0 148 1519 -/+ buffers/cache: 238 14863 Swap: 17279 0 17279 – srvnn Dec 20 '13 at 06:32
  • sorry my bad, I believed that valgrind is actually Java profiler, going to delete my stupid comment – JosefN Dec 20 '13 at 06:34

0 Answers0