profiling with -Xrunhprof
Hi,
I am running a Java process and I am trying to gather memory information using -Xrunhprof. Sometimes it works fine, but sometimes the file ends up only having the minimum of 1974 bytes (which is the header of the file).
Anyone have problems like this before? I am starting my programs from a shell script and when I run the java program in the background (&) I get no memory profile. When I run without the '&' then I get memory profile.
Thanks.
Have you tried using
java -cp ... MyMain < /dev/null &
If you run a java program in the background it tried to read stdin, if a background program tries to read stadin it stop until you put it into the forground so you can type you input.
This can happen even if you know the program does need the input. Using < /dev/null gives the program no input.
Thanks, but my program doesn't take input. Although, I think I figured it out. When running in the background I just kill the process, therefore System.exit never gets called. I seem to be calling System.exit everytime I run in foreground, i.e. I don't kill it before then, so I think that might be it.