As far as troubleshooting the heat:
I have attached 9 volts to the Arduino, via a 12 volt battery stepped down in voltage. That gets hot.
Running it directly off the 12 volt, not dropping the voltage, gets it even hotter. I am confused!
My compile shows plenty of memory left. My Arduino does not have the 5volt or 3.3 volt sources used, at all.
With only data connections and one speaker on the A4 pin, this project should not be getting so hot.
The voltage regulator on the Mega is just a linear regulator. The regulator works by converting ((input voltage -output voltage)*output current) to heat. And the regulator is mounted with a very small amount of copper PCB to dissipate this energy.
I have not been able to obtain current usage figures for the Base Mega2560, but the Ethernet Shield consumes over 150ma so if the Mega uses 50ma that is 200ma usage. Lets calculate
(12v battery) anywhere from 10V(dead) to 14.4(charging High) lets pick 12.8 (float value)
Now, I don't know what the thermal mass the Mega2560 has to dissipate this heat, but 2watts is a lot of heat! for SMT regulators to dissipate.
Here is a good treatise from TI on Heat management design considerations
Just measure the temperature on the regulator. If you cannot hold your finger on it without burning it is over 135 degrees, if you get a second degree burn(blister) on you finger in 5 seconds it is over 155 degrees if you can read the part number off the blister on your finger it is over 190 degrees.
Anything over 155F (68C) is too hot.
NOTE: I recommend using an actual thermometer, fingertips blisters are idiosyncratic, some people have low pain tolerance, and personally this method is contra indicated unless other peoples fingers are used :smiling_imp:
I think your problem is HEAT! The regulator is overheating and shutting down. after continuous use. Create an external power regulator with adequate thermal dissipation (heatSinks).
Check out my Kickstarter Project Memory Panes an expansion RAM Shield for Mega2560's. It adds 1MB of RAM for those projects where 8KB is not enough.