You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been thinking of the possibility of limiting the dynamic allocation of memory in go programs that are to run on embedded devices in such a way that allocation-related issues only can happen during startup of a program.
By not allowing the main() function or any of the functions it calls to allocate any dynamic memory, nor call any functions that does so (recursively), and limit all allocations to happen in the init() function instead. This way any allocation-related issues should be forced to happen during program startup instead of at any random point during the programs lifetime.
By organizing a program something like this (especially the part about global variables and allocating dynamic structures in the init() function), programs could remain relatively readable, but guarantee that any memory allocation issues are caught early.
Would this be a) possible to do at all, enforcing it at a static level? b) feasible/practical, meaning that it would not rule out most if not all of go's standard library, maybe even language features themselves, or even possibly the tinygo runtime?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have been thinking of the possibility of limiting the dynamic allocation of memory in go programs that are to run on embedded devices in such a way that allocation-related issues only can happen during startup of a program.
By not allowing the main() function or any of the functions it calls to allocate any dynamic memory, nor call any functions that does so (recursively), and limit all allocations to happen in the init() function instead. This way any allocation-related issues should be forced to happen during program startup instead of at any random point during the programs lifetime.
By organizing a program something like this (especially the part about global variables and allocating dynamic structures in the init() function), programs could remain relatively readable, but guarantee that any memory allocation issues are caught early.
Would this be a) possible to do at all, enforcing it at a static level? b) feasible/practical, meaning that it would not rule out most if not all of go's standard library, maybe even language features themselves, or even possibly the tinygo runtime?
Beta Was this translation helpful? Give feedback.
All reactions