Skip to main content

As you already got good answers to most of your questions, I will try to cover here only this one:

Is it possible to quantify the fragmentation and get a feel of what's safe safe and when it becomes risky?

A quick Web search for “arduino“Arduino free memory” finds a few code snippets that can be used to measure, at run time, the amount of free memory:

  • Available Memory, in the Arduino Playground, only works on AVR. It measures the total amount of available RAM, including the holes in the heap.

  • Measuring Memory Usage, an Adafruit tutorial, shows some portable (AVR and ARM) code that measures the available RAM between the heap and the stack. This does not include the holes in the heap.

If you compare the AVR versions of these two code snippets, you can see the difference is in the freeListSize() function of the PalygroundPlayground version. This function returns the total memory residing in heap holes, which could be a measure of the heap fragmentation.

The function is AVR-specific, but then AVR is where heap fragmentation is most worrisome.

As you already got good answers to most of your questions, I will try to cover here only this one:

Is it possible to quantify the fragmentation and get a feel of what's safe and when it becomes risky?

A quick Web search for “arduino free memory” finds a few code snippets that can be used to measure, at run time, the amount of free memory:

  • Available Memory, in the Arduino Playground, only works on AVR. It measures the total amount of available RAM, including the holes in the heap.

  • Measuring Memory Usage, an Adafruit tutorial, shows some portable (AVR and ARM) code that measures the available RAM between the heap and the stack. This does not include the holes in the heap.

If you compare the AVR versions of these two code snippets, you can see the difference is in the freeListSize() function of the Palyground version. This function returns the total memory residing in heap holes, which could be a measure of the heap fragmentation.

The function is AVR-specific, but then AVR is where heap fragmentation is most worrisome.

As you already got good answers to most of your questions, I will try to cover here only this one:

Is it possible to quantify the fragmentation and get a feel of what's safe and when it becomes risky?

A quick Web search for “Arduino free memory” finds a few code snippets that can be used to measure, at run time, the amount of free memory:

  • Available Memory, in the Arduino Playground, only works on AVR. It measures the total amount of available RAM, including the holes in the heap.

  • Measuring Memory Usage, an Adafruit tutorial, shows some portable (AVR and ARM) code that measures the available RAM between the heap and the stack. This does not include the holes in the heap.

If you compare the AVR versions of these two code snippets, you can see the difference is in the freeListSize() function of the Playground version. This function returns the total memory residing in heap holes, which could be a measure of the heap fragmentation.

The function is AVR-specific, but then AVR is where heap fragmentation is most worrisome.

Source Link
Edgar Bonet
  • 44.3k
  • 4
  • 41
  • 79

As you already got good answers to most of your questions, I will try to cover here only this one:

Is it possible to quantify the fragmentation and get a feel of what's safe and when it becomes risky?

A quick Web search for “arduino free memory” finds a few code snippets that can be used to measure, at run time, the amount of free memory:

  • Available Memory, in the Arduino Playground, only works on AVR. It measures the total amount of available RAM, including the holes in the heap.

  • Measuring Memory Usage, an Adafruit tutorial, shows some portable (AVR and ARM) code that measures the available RAM between the heap and the stack. This does not include the holes in the heap.

If you compare the AVR versions of these two code snippets, you can see the difference is in the freeListSize() function of the Palyground version. This function returns the total memory residing in heap holes, which could be a measure of the heap fragmentation.

The function is AVR-specific, but then AVR is where heap fragmentation is most worrisome.