-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Official freeRam() command #73
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
2 similar comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
hey guys we now have this +1 function on github, so why not use it instead of spamming? (might not be useable on phones i've heard) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Can someone post the function for AVR? Does anyone has the equivalent for the other architectures? |
AVR
|
Note that the concept of "free RAM" might not be as straightforward as it seems, in particular in the face of dynamic memory allocation and fragmentation, which the above does not consider. This also gives a momentary measurement of the free RAM, with the current stack usage, which people might not understand intuitively. It might still be useful to have such a function, but documentation should be clear on its limitations. |
Here's another version: https://github.com/McNeight/MemoryFree |
@matthijskooijman So if we can add this second info also it is good, but not essential.
|
I think the name is misleading function.
|
This comment was marked as off-topic.
This comment was marked as off-topic.
Being pedantic, none of these examples get the types correct. #include <stddef.h>
inline ptrdiff_t getAvailableStackSpace(void)
{
extern int __heap_start;
extern int * __brkval;
const int stackTop;
return static_cast<ptrdiff_t>(&stackTop - ((__brkval == 0) ? &__heap_start : __brkval));
}
I don't know whether it would be semantically wise to try to cast #include <stddef.h>
inline size_t getAvailableStackSpace(void)
{
extern int __heap_start;
extern int * __brkval;
const int stackTop;
return static_cast<size_t>(static_cast<ptrdiff_t>(&stackTop - ((__brkval == 0) ? &__heap_start : __brkval)));
} |
All mcu project may pay attention on Ram use, and have an official command for print freeRam at runtime it is very important.
For avr there is a well know freeram function, but it do not work on other architecture, like Zero, Due, etc.
So i think that an official freeRam() function is actually very needed inside the Arduino core, and this also would push third-party core authors to work on their implementation of freeRam().
The text was updated successfully, but these errors were encountered: