Quote
if ($sockbr == 0) return
I have added this line, in several places, to the on sockread event in my test script and it has made no difference. I also tried:

if ($sockbr == 0) {
echo 4 sockbr is zero
return
}

The above message never displays because $sockbr is never set to zero, which means /return can never be called. I also added just /return to the script in different places.

&binvars are freed automatically at the end of a script. This is completely independent of what a script does and cannot be prevented. So my guess is that the issue you are seeing is not related to &binvars and is due to something else in your script.

I realize that you are trying to help, and it's possible that there is a bug, but if no one here is able to reproduce it, we really need a test script from you that reproduces the issue for you, so we can try to track it down.

Thanks for your help everyone.