-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.OutOfMemoryError i.e. "Thread-0" or "pool-1-thread-4" #30
Comments
Thank you very much for the report.
|
I have reproduced the error message on three different systems and installed also the resent openJDK. system1: /usr/lib64/jvm/jre-11-openjdk/bin/java -XX:+PrintFlagsFinal -version | grep HeapSize /opt/jdk-21.0.2/bin/java -XX:+PrintFlagsFinal -version | grep HeapSize system2: /usr/lib64/jvm/jre-11-openjdk/bin/java -XX:+PrintFlagsFinal -version | grep HeapSize /opt/jdk-21.0.2/bin/java -XX:+PrintFlagsFinal -version | grep HeapSize size_t ErgoHeapSizeLimit = 0 {product} {default} system3 rasberry Pi 4b: /usr/bin/java -XX:+PrintFlagsFinal -version | grep HeapSize |
All JVMs on the three systems behave as expected. The JVMs (OpenJDK 11 or 21.02.2) set the maximum heap size of 1/4 of physical memory on each machine. In case of the weakest computer in the list, the 4 GiB Raspi, the JVM from the OpenJDK selects 1 GiB for the MaxHeapSize value for example. Well, 1 GiB of allowed Java Heap should be plenty enough memory for Jacksum to do the job! I did some quick tests and limit the max Java Heap to 1 GB on my box, but I cannot reproduce the issue for now. You can allowing the JVM to write a heap dump (a .hprof file) by setting an appropriate JVM option. Please put that option after the
After how many seconds/minutes/hours is that reproducible? |
for system1 after round about 1h the erros occours: Sun Feb 4 01:27:28 CET 2024 Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-0" 8929970313 4. Feb 02:38 java_pid130326.hprof $ /opt/jdk-21.0.2/bin/java -XX:+HeapDumpOnOutOfMemoryError -jar /usr/local/bin/jacksum-3.7.0.jar --threads-hashing max --threads-reading max -a md5 --encoding hex --output-file-overwrite /tmp/jacksum-3.7.0-hashes.txt --error-file /tmp/jacksum.134719.error.txt --file-list-format list --file-list /tmp/jacksum-3.7.0-filelist.txt --verbose summary,warnings --header --path-relative-to /home/OldHome/ /home/OldHome/ Sun Feb 4 09:55:01 CET 2024 Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-0" Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "pool-1-thread-4" 8931432106 Feb 4 11:10 java_pid134723.hprof system2 with jdk21 did not throw an error till now, routhly the same start time. |
Thank you for gathering the Java Heap Dumps. Much appreciated. I have loaded and analyzed the Java Heap dumps using MAT. 99,97 % (1st dump) resp. 99,96 % (2nd dump) of the Java heap is consumed by an instance of a LinkedBlockingQueue called the workQueue which is a member of a java.util.concurrent.ThreadPoolExececutor instance. That queue is used for holding tasks and handing off to worker threads. In Jacksum the instance is being created by calling Executors.newFixedThreadPool(cores); see also
In your cases the producer seems to be much faster than the consumers and the queue have been flooded with 8.3 millions tasks. By default the LinkedBlockingQueue is unbounded which is the reason for the issue I think. I found a description of that problem (and some potential mitigations) very well described at So it seems that fortunately it is not a memory leak by definition, because all data is still needed to do the job, I still cannot reproduce the issue with any of my hardware, but I have created a potential fix for that, so that the producer will need to help with the work before it can delegate work to others if they are all busy. The fix is incluced in the binary attached to this note. Would be great if you could test it and see whether it can avoid the OOM. It is not allowed to upload .jar to notes, so I have packed it using zip as a workaround. |
Great! |
Unfortunately it does not work out, sorry. java -version system1: Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-0" 8914258100 Feb 7 12:16 java_pid11554.hprof |
yes, it looks like my change had no effect at all. It still looks the same as before the change. |
Sorry for causing that much efford and disturbing your weekend. In the meanwhile system2 was also finished system2: Wed Feb 7 16:49:56 CET 2024 Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-0" Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "pool-1-thread-6" 19016693628 Feb 7 18:15 java_pid9784.hprof |
Hi hi! |
My apologies @BlindDuck, I haven't got round to it yet. I will update this ticket soon. |
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-0"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "pool-1-thread-4"
Steps to reproduce the behavior:
$ /usr/lib64/jvm/jre-11-openjdk/bin/java -jar /usr/local/bin/jacksum-3.7.0.jar --threads-hashing max --threads-reading max -a md5 --encoding hex --output-file-overwrite /tmp/jacksum-3.7.0-hashes.txt --error-file /tmp/jacksum.9403.error.txt --file-list-format list --file-list /tmp/jacksum-3.7.0-filelist.txt --verbose summary,warnings --header --path-relative-to /mnt/Nas8BaySammlung/0_neu/ /mnt/Nas8BaySammlung/0_neu/
The directory contains
1309,52GB
7020091 files
281204 subdirs
the parent dir has
2480,08GB
14922770 files
672472 subdirs
an other dir contains
1289,23GB
1287811 files
115790 subdirs
2/4. See the output/error:
"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-0"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "pool-1-thread-4"
"
Expected behavior:
a smooth run through as on the other processed directories.
i.e /usr/lib
jacksum.95988.report.txt
jacksum.95988.output.txt
jacksum.95988.error.txt
jacksum.95932.output.txt
jacksum.95932.error.txt
env.txt
The text was updated successfully, but these errors were encountered: