¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: freeMemory()


 

will do.? Thanks ashar!
See elsewhere:? ?I have the assist?working better


On Thu, Apr 16, 2020 at 11:07 AM Ashhar Farhan <farhanbox@...> wrote:
I suggest that we immediately start using github. It is the only way to NOT wait for each other to finish the code.
Take a break for 20 minutes and watch this


On Thu 16 Apr, 2020, 8:15 PM jjpurdum via , <jjpurdum=[email protected]> wrote:
Gordon:

Add this line to line 73 in vent.h

??? extern char *__brkval;????????// leading double-underscore to prevent name collisions

and around line 139 in the same file, insert:

??? int freeMemory();???????????? // Function prototype

Add this line around line 101 in the INO file:

????char *__brkval;

Finally, add this function block to the INO file around line 179:

/
?? Purpose: To measure the runtime amount of SRAM memory available at the point where called

?? Parameter list:
??????? void

?? Return value:
??????? int??????? the amount of remaining free SRAM at the point called

?? CAUTION: ?????? Function assumes that Arduino.h is #include'd in the project
/
int freeMemory()
{
? char top;

? return __brkval ? &top - __brkval : &top - __malloc_heap_start;
}

When you wish to measure SRAM at a point in the program, insert:

? Serial.print("============ free memory: ");
? Serial.println(freeMemory());

I cannot test it on the vent code because of the runtime test for the pressure sensor, which hangs my system.
Let me know if it doesn't work.

Jack, W8TEE

Join [email protected] to automatically receive all group messages.