Skip to content

TIFFDeflator blocks GC due to long-held native critical section #292

@davispw

Description

@davispw

TIFFDeflator calls ZipDeflateCompressor in a single chunk with a large output byte[], which makes a single call to Deflater.deflate(), whose native implementation calls GetPrimitiveArrayCritical to pin memory (openjdk source). This suspends GC until compression finishes, which can take some time, especially for larger images. In a busy multithreaded process, if younggen fills up, this can block all JVM memory allocation, which is very bad. (Explanation: https://shipilev.net/jvm/anatomy-quarks/9-jni-critical-gclocker/)

It looks like this would also be an issue with libdeflate-java: see compressor.c and LibdeflateCompressor.java.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions