Chronicle-Queue icon indicating copy to clipboard operation
Chronicle-Queue copied to clipboard

Pretoucher doesn't unmap file

Open pedegie opened this issue 3 years ago • 1 comments

Hello I noticed that after executing pretoucher only once it still keeps mmaped file after recycle. Then its eventually overridden later on next execute(). Code example:

        var queue = SingleChronicleQueueBuilder
                .binary(Paths.get(System.getProperty("java.io.tmpdir"), "stats_queue", "stats_queue1.log").toAbsolutePath())
                .rollCycle(RollCycles.MINUTELY)
                .build();

        var appender = queue.acquireAppender();
        var bytes = Bytes.elasticByteBuffer();
        var pretoucher = new Pretoucher(queue);
        pretoucher.execute();
        while(true)
        {
            Thread.sleep(5000);
            try (DocumentContext dc = appender.writingDocument())
            {
                dc.wire().bytes().write(bytes);
            }
        }
kacper@kacper:~$ pmap -x `pgrep -f "Test"` | grep cq4
00007fd672000000   81920      12      12 rw-s- 20211221-2247.cq4
00007fd677000000   81920      36       4 rw-s- 20211221-2246.cq4
00007fd74802b000     128      64       4 rw-s- metadata.cq4t

In case we need to pretouch only once, at load-time there is no way to unmap file because shutdown() method also closes Queue.

pedegie avatar Dec 21 '21 22:12 pedegie

@Roger can you check if this is still the case ?

RobAustin avatar May 06 '22 14:05 RobAustin

@pedegie you are expected to call execute regularly. If you call close on the pretoucher (not shutdown - this method will be deprecated/deleted) then that will release all resources.

JerryShea avatar Sep 26 '22 01:09 JerryShea