You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In your testProto function, you create a new client object, but you never close that client. Because of that, it continues to retain memory after you stop using it. We recommend creating a single client and using it for every request, but if that is not an option, you should at least call client.close() when you are done with it.
Create a client in Node.js and use it for each request (with real-time refresh), and whether there is a need to close or perform other operations afterwards.
Which of the following two methods is better in terms of performance
Create a client for each request
Call client. close() after each request is completed
Your best option is to create a single client object, and use that single client to make every request. This performs better because it ensures that resources such as connections are reused as much as possible.
Your other option is to create a client for each request and call client.close() after the request completes.
Problem description
Update to [email protected] Version, experiencing continuous memory growth issue
Reproduction steps
nodejs:
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const packageDefinition = protoLoader.loadSync(
proto文件路径,
{
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
},
);
const dataService = grpc.loadPackageDefinition(packageDefinition);
// The testProto() access is called in real-time and requests every 3 seconds
export const testProto= () => {
const grpcOptions = {};
const client = new dataService.DataMessage(URL, grpc.credentials.createInsecure());
return new Promise((resolve, reject) => {
client.getInfo(grpcOptions, (err, output) => {
if (err) {
reject(err);
} else {
resolve(output);
}
});
});
};
The text was updated successfully, but these errors were encountered: