¿ªÔÆÌåÓý

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

Re: freeMemory()


 

Yes, I saw that, but I still would not be able to get meaningful trials of anything in the system, other than exercising the menus. Also, the runtime memory use for data would likely be different than the "real" thing.

Jack, W8TEE

On Thursday, April 16, 2020, 11:04:12 AM EDT, Gordon Gibby <docvacuumtubes@...> wrote:


jack -- you can DISABLE the jams that I put in to keep the bmp working no matter what -- and then it will FAIL and from then on will no longer use the BMP sensor.? ?That will allow you to run the code without problems.? ?
Gordon


On Thu, Apr 16, 2020 at 10:45 AM 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.