MatlabProcessManager icon indicating copy to clipboard operation
MatlabProcessManager copied to clipboard

Error in destructor

Open ChristianStadelmann opened this issue 3 years ago • 0 comments

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.

ChristianStadelmann avatar Dec 05 '22 13:12 ChristianStadelmann