-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pubsub: client cause memory leak #5265
Comments
Transferring this issue to the correct repo. |
Thanks for reporting. What is your publish rate? Also, is there anything underneath the last line, |
I am so sorry. I checked this situation. Solution is here. func PullMessage(w io.Writer, projectID string, subID string) error {
ctx := context.Background()
client, err := pubsub.NewClient(ctx, projectID, option.WithCredentialsFile("./auth_env.json"))
if err != nil {
log.Errorf("PubSub Credentials Error : ", err)
return err
}
defer client.Close()
sub := client.Subscription(subID)
sub.ReceiveSettings.Synchronous = true
sub.ReceiveSettings.NumGoroutines = 32
sub.ReceiveSettings.MaxOutstandingMessages = 32
ctx, cancel := context.WithCancel(ctx)
ctx, _ = context.WithTimeout(ctx, 60*time.Second) // Receive messages for 60 seconds. If timeout then Deadline Except occur.
defer cancel() As my code write, difference occur with example. difference is timeout function. BEFORE sub := client.Subscription(subID)
sub.ReceiveSettings.Synchronous = true
sub.ReceiveSettings.NumGoroutines = 32
sub.ReceiveSettings.MaxOutstandingMessages = 32
ctx, cancel := context.WithCancel(ctx)
ctx, _ = context.WithTimeout(ctx, 60*time.Second) // Receive messages for 60 seconds. If timeout then Deadline Except occur.
defer cancel() AFTER sub := client.Subscription(subID)
sub.ReceiveSettings.Synchronous = true
sub.ReceiveSettings.NumGoroutines = 32
sub.ReceiveSettings.MaxOutstandingMessages = 32
ctx, cancel = context.WithTimeout(ctx, 60*time.Second) // Receive messages for 60 seconds. If timeout then Deadline Except occur.
defer cancel() However, if a similar error occurs again, I will write an issue again. |
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is this a client library issue or a product issue? We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.
If the support paths suggested above still do not result in a resolution, please provide the following details.
Environment details
Steps to reproduce
1. I try coding to this example.
2. I founded at this example that memory leak accident.
3. Therefore i inserted code that use garbage collection when GCP PubSub Client pull message.
4. Even after doing this solution, memory leak occur. I don't know that cause memory leak when subscription client receive GCP PubSub message.
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
The text was updated successfully, but these errors were encountered: