Recursive queries may leak some amount of memory from the request pool. This may be a big problem if the request is a trigger or a procedure, as this memory never gets deallocated until disconnection (or trigger/procedure recompile). In the test I have at hands (cannot be shared, unfortunately) every insert leaks about 20MB because of this issue (WITH RECURSIVE in the AFTER INSERT trigger).
All the leaked memory chunks are allocated in VIO_record():
record = rpb->rpb_record = FB_NEW_RPT(*pool, format->fmt_length) Record(*pool);
and lost after this code in RSBRecurse::get():
// Don't overwrite record contents at next level of recursion.
// RSE_open and company will allocate new record if needed
rpb->rpb_record = NULL;
I have tried the following solution in RSBRecurse::close():
char* tmp = irsb->irsb_stack;
memcpy(irsb, tmp, inner_size);
+ char* p = tmp + inner_size;
+ for (int i = 0; i < streams; i++)
+ record_param* rpb = (record_param*) p;
+ delete rpb->rpb_record;
+ p += sizeof(record_param);
and it seems to help (leaks disappear). Maybe a better solution could be suggested instead.