need a way to check for memory errors.

Don't allocate memory - the arduino has very little ram. Decide how much you'll need up front and declare it statically.