Answer
A MALLOC_FAIL can occur for 2 reasons.
- There is no more space in RAM
- The heap is fragmented*
The latter can be resolved by calling reset() which will reset the module and defragment the heap. If there is enough contiguous memory freed up by the defragmentation, the issue is then resolved.
For the former, you will have to reconsider the use and scope of the variables and structures in your smartBASIC application.