And is there a way of managing the memory
You "manage the memory" by not wasting it. No variables larger than they need to be. No arrays larger than they need to be. No unnecessary strings in SRAM. No Strings AT ALL.
If these still cause you to run out of memory, you need an Arduino with more memory.