I am running a program on the ATtiny and for some reason I am way over the 512 bytes of RAM that are available to me. This is confusing because when I did the math by hand I should have 432 bytes. Here is my code:

#include <SoftwareSerial.h>

#define FASTADC 1

// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

SoftwareSerial mySerial(0,1);    //This uses 47 bytes of RAM

byte i = 0;      This uses 1 byte of RAM

byte pixelsArray1[128];   //Arrays use 128 bytes of RAM each
byte pixelsArray2[128];
byte pixelsArray3[128];

void setup() 
// set prescale to 16

pinMode(1,OUTPUT);        //Setting the 1 pin to be used for output 
pinMode(0,OUTPUT);        //Setting the 0 pin to be used for output
pinMode(A3,INPUT);         //Input for Camera 3
pinMode(A2,INPUT);         //Input for Camera 2
pinMode(A1,INPUT);         //Input for Camera 1

mySerial.begin(9600);     //Setting the data transfer rate

It's telling me that I am using 510 Bytes of memory but my math gave me 432 bytes of RAM. Does anyone see what I'm missing?

  • You should ask avr-objdump. Commented Jun 14, 2016 at 14:23
  • Out of interest how did you come up with your 432? Commented Jun 14, 2016 at 14:30
  • 3*128 Arrays + 47 SoftwareSerial + 1 byte variable = 432
    – sgmm
    Commented Jun 14, 2016 at 14:36
  • Which ATtiny are you using? Are you using SoftwareSerial for sending, receiving or both? Commented Jun 14, 2016 at 14:40
  • I'm using the ATtiny85 which has 512 bytes of RAM. Also I'm using the ATtiny to program a camera so I'm assuming that SoftwareSerial is used for both. Sorry, but this is my first Arduino Project ever.
    – sgmm
    Commented Jun 14, 2016 at 14:42

1 Answer 1


There is a lot you are missing. Such as:

  1. SoftwareSerial is using RAM.
  2. The system stack is using RAM.
  3. The Arduino core software is using RAM.

There's plenty more going on than just your sketch. For instance, where do you think it stores the current millis() and micros() counts? Where do you think incoming serial data gets buffered? Where do you think your registers, PC, etc, get stashed when a function (such as setup()) is called? All that takes RAM.

  • She already counted SoftwareSerial, and the stack is not in the 510 bytes reported by the compiler. So this leaves only the Arduino core. Commented Jun 14, 2016 at 14:36
  • So is there any way I can reduce the amount of memory being used without scrapping my Arrays? For example, is there a way to NOT store the current millis() and micros() or is there an alternative to SoftwareSerial?
    – sgmm
    Commented Jun 14, 2016 at 14:38
  • You should use avr-objdump to examine all the section sizes and determine what can be removed - then remove it. That means manual editing of core code.
    – Majenko
    Commented Jun 14, 2016 at 14:41
  • How can I edit the avr-objdump? It's a .exe file and how do I know what I can remove. Again, I'm sorry but this is my first ever Arduino project.
    – sgmm
    Commented Jun 14, 2016 at 14:44
  • You don't edit avr-objdump - you use it to examine your .elf file. That will allow you, if used right, to list all the variables in your .elf file. You can then look to see what there is. You can then match those up to variables in the core software and determine if you need the functionality associated with those variables - and if not then delete it wholesale.
    – Majenko
    Commented Jun 14, 2016 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.