Skip to content

Please dont call System.gc #11

@AlexanderSchuetz97

Description

@AlexanderSchuetz97

Hello there,
your calling System.gc in openize.heic.decoder.io.BitStreamWithNalSupport#deleteImageContext
this functions gets executed for every row in the image. I am parsing an 8000x8000 pixel heic image,
meaning the garbage collector gets invoked 8000 times.

This is slow.
I used a hex editor to replace the INVOKESTATIC instruction that calls system.gc with a NOP and my performance went up by about 20 seconds.
With System.gc it takes me 1 minute to parse the image. Without System.gc (NOP Patch) it takes 40s. (~30% gain)
The JVM knows best when it runs out of memory itself, there is usually no need to call System.gc.

If you insist on leaving this in, could you please give us a parameter to set to false or something so I can disable this for my use?
I would prefer not having to use a hex editor everytime you update your library if at all possible.

Something like

private static final DO_GC = !"true".equalsIgnoreCase(String.valueOf(System.getProperty("openize.heic.decoder.gc.disable"));

and then in the method you can do

if (DO_GC) {
System.gc();
}

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