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

I typed php --ini to check which php.ini file is being used by PHP. So it is the correct one. And there is only one version of PHP installed on this server. Also the value -1 is valid for memory_limit.

memory_limit [integer]

This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1 .

Source: PHP: Description of core php.ini directives - Manual