You can check that the method initializes correctly by testing the returns of setCacheStorageMethod (true/false).
You can also verify that the memory_limit setting is taken into account (the reached 512 MB while the setting is set to 1024MB is curious) displaying or storing the results of an ini_get('memory_limit'). If you do not have the same value, somewhere a configuration file change the value, but you must be able to impose it in the script even (memory_limit is PHP_INI_ALL)
For the phpTemp, the memoryCacheSize is misleading, in fact this value corresponds to the memory that php has the right to use before writing to disk, so increasing it always generates problems.
In addition, if I read correctly the documentation, the value must be specified in bytes, nowhere is mention with a capacity of the wrapper to take into account the short notation (K, M, G), I know not how a value like 512 MB is interpreted, as well for the value that is used by default by Mark (1 MB), therefore, unless test this, I would try 2097152 (2 MB, the default value according to the php documentation - this same documentation where the example clearly shows the conversion of 5 MB in the equivalent in bytes for the passage of the parameter)
You can also verify that the memory_limit setting is taken into account (the reached 512 MB while the setting is set to 1024MB is curious) displaying or storing the results of an ini_get('memory_limit'). If you do not have the same value, somewhere a configuration file change the value, but you must be able to impose it in the script even (memory_limit is PHP_INI_ALL)
For the phpTemp, the memoryCacheSize is misleading, in fact this value corresponds to the memory that php has the right to use before writing to disk, so increasing it always generates problems.
In addition, if I read correctly the documentation, the value must be specified in bytes, nowhere is mention with a capacity of the wrapper to take into account the short notation (K, M, G), I know not how a value like 512 MB is interpreted, as well for the value that is used by default by Mark (1 MB), therefore, unless test this, I would try 2097152 (2 MB, the default value according to the php documentation - this same documentation where the example clearly shows the conversion of 5 MB in the equivalent in bytes for the passage of the parameter)