--- In [email protected], "brucexs" <bruc...@...> wrote: > > > > > > > It means that a handle isn't being freed. Second time into script, > > c\0x05_003 should be free, but it's not, plugin uses next free hanlde, so > > c\0x05_004. > > Note from detailed steps in previous note that the above behaviour is > expected. The foreach var will get freed by the setvar calling back to your > free routine, but this routine is after you have generated the handle. > > As a test and possible workaround, before generating a new handle (but after > confirming that there are more items in the collection) , setvar the foreach > variable to "". This should free the old handle. Or simply free it yourself > at the start. By free I mean dec the ref count. >
On re-reading above, manually freeing is not a good idea since you still should call setvar, which will also call your free routine. So setvar it to "" seems the best idea, assuming you can do that before generating a new handle but after checking there are still items to be generated. (if you setvar to "" first, you won't break anything, but that would be a slightly different behaviour that other for each).
