Memory leak when creating many ImageAnnotatorClient instances
See original GitHub issueUnsure what the root cause of the issue is but I noticed that creating a lot of ImageAnnotatorClient instances causes a consistent rise in unmanaged memory (first guess is - it’s creating a lot of HttpClients):
I was initialising a ImageAnnotatorClient per image and I am sending 50-100 images per second so I was quite quickly running out of memory. Now, I just reuse the same ImageAnnotatorClient for each batch of images and I now see fairly consistent memory usage (sorry for the differing pictures, the bottom graph shows the unmanaged memory - and it’s basically flatlined):
I was just wondering whether:
- It’s okay to reuse the client, several hundred times?
- Whether I’ve exposed a bug (maybe something isn’t being GC’d?)…
Is this possibly a duplicate/symptom of this issue or perhaps this issue
These are my installed packages:
<package id="Google.Api.CommonProtos" version="1.2.0" targetFramework="net46" />
<package id="Google.Api.Gax" version="2.2.1" targetFramework="net46" />
<package id="Google.Api.Gax.Grpc" version="2.2.1" targetFramework="net46" />
<package id="Google.Apis" version="1.32.2" targetFramework="net46" />
<package id="Google.Apis.Auth" version="1.32.2" targetFramework="net46" />
<package id="Google.Apis.Core" version="1.32.2" targetFramework="net46" />
<package id="Google.Cloud.Vision.V1" version="1.1.0" targetFramework="net46" />
<package id="Google.Protobuf" version="3.5.1" targetFramework="net46" />
<package id="Grpc.Auth" version="1.10.0" targetFramework="net46" />
<package id="Grpc.Core" version="1.10.0" targetFramework="net46" />
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
What are the things I should avoid in my python Cloud ...
1 Answer. explicitly delete the temporary variables that you allocate on the bots processing path, which may be referencing each-other thus ...
Read more >Investigating Memory Leaks in Google Cloud Datastore ...
A memory leak occurs when a program allocates memory but fails to release it when it is no longer needed. Over time, these...
Read more >GAE - Nodejs - Memory leak for a simple pubsub app
You may not be experienceing a memory leak, but may just be constrained by the memory available. The default instance class of App...
Read more >RAM isn't freed after a request in my Cloud Run service?
It certainly feels like a "memory leak". If we imagine a request being received, the request is processed by a Docker image that...
Read more >How to Handle Google Cloud Pub/Sub Memory Leaks on ...
The memory leak issue on re-deploy occurs when the Netty-based client tries to close the connection to the Google Cloud Pub/Sub server. When...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay, great that makes perfect sense. In case anyone else is reading and finds they have the same problem I modified my code to be:
Thanks Jon!
Note that if you’re using this from multiple threads, you may want to use
Lazy<T>
instead: