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

C memory management functions #17

Open
OxMarco opened this issue Sep 2, 2017 · 3 comments
Open

C memory management functions #17

OxMarco opened this issue Sep 2, 2017 · 3 comments

Comments

@OxMarco
Copy link

OxMarco commented Sep 2, 2017

Usually in embedded uC it is not recommended to use low-level memory management functions.
Can you think of possible workarounds, including checking if there's enough free memory to run dynamic allocation?

@jonblack
Copy link
Owner

jonblack commented Sep 2, 2017

You're right that allocating dynamic memory in embedded systems is generally not a good idea. As far as I'm aware you're relatively safe as long as you don't free up memory that's been allocated (causing fragmentation).

That said it's possible to adapt the library to define a constant number of transitions.

Have you noticed anything funky?

@OxMarco
Copy link
Author

OxMarco commented Sep 2, 2017

Up to now no, I would like to use this FSM within FreeRTOS applied to robotics so I am afraid there might be stability issues when dealing with dynamic memory allocations.
Just to be sure, I would add a method to statically initiate the fsm object without using malloc and similar.

@jonblack
Copy link
Owner

jonblack commented Sep 2, 2017

Unless your dynamically changing your state machine (not sure what the use case would be for that) you should be building your state machine in setup. After that no memory allocation is done, so you should be fine.

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