Unable to use gif images in plugin with v4.3.1

I just upgraded a website from v3.7.11 to v4.3.1. The website uses a plugin where a record contains a gallery via the fileupload form field. The mode is image and the maxFiles is set to 12. When trying to load a record containing 1 gif (approx 300kb) and 6 webp images (all under 300kb) I get the following error:

Allowed memory size of 536870912 bytes exhausted (tried to allocate 5760001 bytes)

{
    "exception": {
        "class": "Symfony\\Component\\ErrorHandler\\Error\\FatalError",
        "message": "Allowed memory size of 536870912 bytes exhausted (tried to allocate 5760001 bytes)",
        "code": 0,
        "file": "~/vendor/intervention/gif/src/Splitter.php",
        "line": 206,
        "trace": []
    }
}

The PHP memory limit is set to 512MB. It works fine on v3.7.11, but not on the latest version.