I found an issue with my use of setFinal to free allocated strings that was causing a memory leak. I hadn't appreciated a behavioural detail of setFinal, though it seems obvious now I know. In particular, for setFinal f v, it is (the C value referenced by) v at the time f is called, not at the time f is registered using setFinal, that is passed to f.
To help me understand exactly what is going on, I wrote some notes on setFinal covering matters in detail - see attached. I don't know how accurate this is though. Although the detail is, perhaps, excessive for some users, I found a low-level description quite useful.
Phil