Skip to content
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

available RAM check? #81

Closed
ghost opened this issue Apr 18, 2015 · 3 comments
Closed

available RAM check? #81

ghost opened this issue Apr 18, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 18, 2015

On atmega based boards, we were used to retrieve available memory like this:

uint8_t *heapptr, *stackptr;

unsigned long FreeMem(void)
{
stackptr = (uint8_t *)malloc(4); // use stackptr temporarily
heapptr = stackptr; // save value of heap pointer
free(stackptr); // free up the memory again (sets stackptr to 0)
stackptr = (uint8_t *)(SP); // save value of stack pointer
return (stackptr-heapptr);
}

It does not compile for ESP. Anyone that knows how to do it?

On NodeMCU there is Node.Heap()

@Links2004
Copy link
Collaborator

you can use

extern "C" {
#include "user_interface.h"
}
uint32_t free = system_get_free_heap_size();

@igrr
Copy link
Member

igrr commented Apr 18, 2015

Perhaps we should add this heap() method to the ESP class.

On Sat, Apr 18, 2015 at 9:31 PM, Markus notifications@github.com wrote:

you can use

extern "C" {
#include "user_interface.h"
}uint32_t free = system_get_free_heap_size();

Reply to this email directly or view it on GitHub
#81 (comment).

@ghost
Copy link
Author

ghost commented Apr 18, 2015

Thanks! Got it to work. Nice to see that we have a lot more mem than with the old Atmega2560...

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants