Ram problem Mega2560

saturating the flash memory is not an issue, it's there to be used.

Keeping some SRAM available for dynamic allocations (bad idea if memory is scarce) and the stack is a good idea

get a more capable board, use alternative libraries, clean up your code.... with the information we get, we can't provide any advice...