ESD Download Gives Error

When I want to download an esd file which is over 256 mb it gives this error,

Fatal error : Allowed memory size of 268435456 bytes exhausted (tried to allocate 432861184 bytes) in  /home2/rafasolu/public_html/rafasolutions/engine/Shopware/Controllers/Frontend/Account.php  on line  408

,but when I change the memory_limit of php to 512M it gives this error

Fatal error : Out of memory (allocated 33816576) (tried to allocate 432861184 bytes) in  /home2/rafasolu/public_html/rafasolutions/engine/Shopware/Controllers/Frontend/Account.php  on line  408

 

How to fix this?