I’m running a script where I want to get byte channel from file. Everything works fine, “apparently”. because when ever I try to delete the file I’m getting this
Do you have to use a memory mapped file for some reason?
These work in a OS-dependent manner and the memory/file isn’t released until the buffer is GC’d. Your channel close is meaningless because you still have a buffer pointing to memory the file has been mapped to.
The reason is because is the most efficient method to compare objects.
byteBuffer1.equals(byteBuffer2)
The idea is to determine if content of files are the same, beyond the comparison of file names. Trying to collect bytes has became challenging for xlsx big files, about 100Mb.
I was using readAllBytes() but from time to time I was getting OutOfMemory Exceptions.
Right, I was delighted by the speed of mapped files using this approach.
Just an additional question, How much time would take the GC to act over these files. About 20 mins according to this graph maybe? or that is not even related?
Maybe, but there could be smaller collections happening in between the big ones that don’t register on the graph. You’d have to turn on GC logging to see when it’s actually happening. And even then it would vary depending on what the gateway is up to.
You can request a GC be done by calling System.gc().
I’m curious what the performance difference between the regular code with varying buffer sizes and the memory mapped files is.
edit: comparing two equal 105MB files (worst case is when they are equal) with varying buffer sizes:
true
bufferSize=1024 took 1015ms
true
bufferSize=2048 took 456ms
true
bufferSize=4096 took 261ms
true
bufferSize=8192 took 140ms
true
bufferSize=16384 took 83ms
true
bufferSize=32768 took 54ms
true
bufferSize=65536 took 38ms
true
bufferSize=131072 took 31ms
true
bufferSize=262144 took 30ms
true
bufferSize=524288 took 36ms
true
bufferSize=1048576 took 85ms
Shouldn't be an statement fo r r2 != -1 as well, like below?
Good, the script works but I'm having way worst performance compared to your results (buffer = 262144). Way worst, like 30 seconds hehe.
Increasing the buffer to 2^23 did not make a huge difference.
Running from script console, designer with 4GB memory