This tripped me up for a few hours – if you upload a large image and get the memory limit error, you have to go in manually (SSH, FTP, etc.) and delete that image. Otherwise you will never be able to upload to that gallery again, even if you delete it and recreate it. The large image will just stay there and give you memory errors ad infinitum.