-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
The NodeJS gapic clients seem to have a memory leak that can be triggered using the following steps:
Open a gapic client.
Execute one simple request.
Close the gapic client.
Repeat.
This issue was reported for NodeJS Spanner client library. Internal customer was trying to investigate memory leak issue in Spanner Autoscaler which led them to discover memory leaks in NodeJS Spanner client. Please refer issue . When investigated this further it seems to be more of a generic problem with the generated gapic clients.
Running a simple script that opens a simple generated client, executes one request with it and then closes the client will now leak approx 3MB after 100 iterations.
Test Script
const {Spanner, v1} = require('@google-cloud/spanner');
const REPETITIONS = 100;
console.log(`Running ${REPETITIONS} times`);
function main() {
async function test() {
for (let i = 0; i < REPETITIONS; i++) {
await useGapic();
global.gc();
const used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`${i}: Current mem usage ${Math.round(used * 100) / 100} MB`);
}
}
async function useGapic() {
const client = new v1.InstanceAdminClient({
projectId: 'my-project',
keyFile: '/path/to/my-key.json',
});
await client.listInstanceConfigs({
parent: 'projects/my-project',
});
await client.close();
}
test();
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main();
This is continuation to what was also reported in bug
Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.