Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Esp8266 Freeram

Status
Not open for further replies.

dr pepper

Well-Known Member
Most Helpful Member
Another esp question
I came across a piece of code in a program that calculates how much memory is available for data acquisition.
The code quotes 'freeRam' as a variable, the compiler rejects it and says it hasnt been defined, and obviously the program doesnt define it either.
I've updated my core and tried different esp boards, but cant get it to work.
Looking on the net there is very little info on arduino freeRam.
I rem'd out the line with the if statement and the code compiles & runs, but I get less memory than expected.
Any ideas?

Code:
  //Get free RAM
  freeRAM = system_get_free_heap_size();
if (freeRAM < lowestRAM    )  lowestRAM = freeRAM;
  Serial.print("  freeRAM : ");
  Serial.print(freeRAM);
  Serial.println(" bytes ");
 
Last edited:
I found this, dont know if it'll work, the site was in another language, but it seemed to be the same issue:

Code:
*/
// needed to avoid link error on ram check
extern "C"
{
#include "user_interface.h"
}
 
Another esp question
I came across a piece of code in a program that calculates how much memory is available for data acquisition.
The code quotes 'freeRam' as a variable, the compiler rejects it and says it hasnt been defined, and obviously the program doesnt define it either.
I've updated my core and tried different esp boards, but cant get it to work.
Looking on the net there is very little info on arduino freeRam.
I rem'd out the line with the if statement and the code compiles & runs, but I get less memory than expected.
Any ideas?

Code:
  //Get free RAM
  freeRAM = system_get_free_heap_size();
if (freeRAM < lowestRAM    )  lowestRAM = freeRAM;
  Serial.print("  freeRAM : ");
  Serial.print(freeRAM);
  Serial.println(" bytes ");

Does that code only run on an Arduino?, and not on an ESP? - it might be processor specific?.
 
I think its for the Ide, so it'll work on any chip.
 
I think its for the Ide, so it'll work on any chip.

I'm less confident of that - the IDE is basically just a text editor, and transfers the text file created to the respective compiler, linker etc.

It sounds like the variable FreeRAM is probably created, and 'filled in' by some routine in the Atmel compiler?.

Have you tried the code on an Arduino?.
 
"freeram" is just a variable.

This is the key line:
freeRAM = system_get_free_heap_size();


It's returning the space on the runtime "heap". That is not the total of the available device memory, just the section allocated by the compiler or runtime for heap space.

It will also have reserved some stack space and possibly other regions, with many compilers.

Whether it does anything sensible on any given system depends on the compiler or libraries in use having the "system_get_free_heap_size()" function.
 
Yes you'd be right mt jenkins, if I wasnt a twonk.
The problem is lowestRam, not freeRam.
I searched the whole code for lowestRam, its not defined anywhere, freeRam is defined further up.
 
lowestram is just another simple variable, as in your first post.

It will be initialised somewhere to an impossibly high value then each time freeram is set, lowestram is compared and set down if freeram is less than the lowest previously stored.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top