In my code, I create a processManager object. When it goes out of scope, i.e., when Matlab decides to call the destructor, I sporadically¹ see this error message:
The following error was caught while executing 'processManager' class destructor:
Error using timer/stop (line 34)
Invalid timer object. This object has been deleted and should be removed from your workspace using CLEAR.
Error in processManager/delete (line 483)
stop(self.pollTimer);
I guess that this is a race condition between the destructor and the timer's stop() function calling pollTimerStop().
Would it help to turn pollTimerStop() into a non-static function which not only deletes the timer at the end, but also sets this.pollTimer = [];?
¹ sporadically in this context means something like once in 100 executions.
In my code, I create a processManager object. When it goes out of scope, i.e., when Matlab decides to call the destructor, I sporadically¹ see this error message:
I guess that this is a race condition between the destructor and the timer's
stop()
function callingpollTimerStop()
.Would it help to turn
pollTimerStop()
into a non-static function which not only deletes the timer at the end, but also setsthis.pollTimer = [];
?¹ sporadically in this context means something like once in 100 executions.