creditkarma / thrift-typescript

Generate TypeScript from Thrift IDL files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generated recv_ function leaks memory when used with apache thrift client

jlai opened this issue · comments

commented

Noticed a memory leak when trying to use the thrift-typescript generated classes (--target apache with the apache thrift library's thrift client. The issue is https://github.com/apache/thrift/blob/234e80e1b9acb1bc778c7adfaa6cb695d922d5f0/lib/nodejs/lib/thrift/connection.js#L125 which injects an entry (with a negative sequence number) in _reqs for each request.

The recv_ functions generated by the apache thrift code generator adds delete this._reqs[rseqid]; to clean it up. thrift-typescript does not, so it leaks memory -- potentially a lot especially for framed transport due to its use of buffer.slice() internally.

Possibly this ought to be fixed on the apache thrift library side (poor separation between the connection and client class code) but figured the discrepancy/leak should be noted here since this library tries to provide a mostly-compatible code generation of the thrift client classes.