B4R Question fatal stack error at timer?

Hans- Joachim Krahe

Active Member
Licensed User
Longtime User
I set tmr.enabled = false at begin of a sub und tmr.enabled = true at the end - causes a regular fatal error after about 2500 times - exact at the same loop, depending on stack largeness.....

after replacing timer.enable by a boolean inside the tmr routine for not executing the tasks, the error was gone. at stackbuffersize(10000), the error was earlier than on stackbuffersize(300) ... might be interesting...

should a var for timercounter be set in globals? guess, he will define his own vars for looping
 

Hans- Joachim Krahe

Active Member
Licensed User
Longtime User
!!! :) true of course, but I wanted to reset the timer too, because its responsible for the power discharge of the motor. Counter should start with zero after motor working - but no problem to change the solution...
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Your code is expected to fail as you are not letting the disabled scheduler nodes to be released so the scheduler needs to create more and more nodes.

A more realistic code works properly:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Public tmr As Timer
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   tmr.Initialize("timer_tick",1)
   tmr.Enabled = True
End Sub

private Sub timer_tick
   tmr.Enabled = False
   Log(AvailableRAM)
   tmr.Enabled = True
End Sub
The available ram is constant.
 
Upvote 0
Top