ladyada’s ranting afowejfaiwuehfakjnfa

Free up some Arduino SRAM

Here is a slightly advanced hack. If you have a project that needs lots of ram for buffering data or other nonsense, you can get 10% more by cutting down the ram used in the Serial library. Unless you’re doing a project with a lot of Serial data coming in, you wont need 128 characters…I find 16 or 32 is plenty!
Open up hardware/cores/arduino directory, and edit the file named wiring_serial.c

Near the top is a #define RX_BUFFER_SIZE 128, which means 128 bytes are used for the buffer. You can change this to 32 (or even 16!). If you have almost no serial input, make it as low as you’d like as long as its > 0.

You can get another 2 bytes by changing the head and tail index values from int to uint8_t type. Just recompile your sketch and it will automatically do your thing.

Check out more hacks here…

Leave a Reply

You must be logged in to post a comment.