To reduce the memory I had to convert many sprites to tiles, put many sprites in 1 and use the minimum size of sprite sheets.
Now the game needs a maximum of 380 megabytes (before almost 600). 380 is not much, but it requires a lot of extra optimization work.