0

we are using golang 1.16. for developing a microservice which exports product data to shopify. the microservice is starting a grpcserver. our java client starts the export of the items via calling the endpoint "SendAllItems" on grpc Server. then the endpoint reads 20.000 Products from database, convert them into json objects and send them to shopify. we see now the strange behaviour that on linux the memory usage of the service increases to 8 GB and it gets not released any more. when we profile the service we see it uses round about 70 MB. pprof: enter image description here

htop on linux: enter image description here

we already added at the end of function the command debug.FreeOSMemory() and tried to set all slices which could use too much memory to nil after usage but no chance to decrease the memory. the only thing which takes effect is to restart the whole grpcserver.

do you habe any idea what else we are able to check?enter image description here

  • Are you doing it in goroutines ? Do you control the size of spawned goroutines? – Roman Kiselenko Oct 29 '21 at 07:58
  • Go heap memory never shrinks, only grows. If your heap is 8 GB then it means your process had a peak memory usage around 4 GB at some point in the past. You need to find a moment when heap usage is high and take a goroutine and heap dumps at that time. – rustyx Oct 29 '21 at 11:54

0 Answers0