Hi,
I'm developing speech-to-text inference server with cpp libraries 
(wav2letter)

according to runtime docs 
(https://golang.org/src/runtime/proc.go?s=108905:108924#L3803), 

"A goroutine should call LockOSThread before calling OS services or non-Go 
library functions that depend on per-thread state"

The current server process as fallow

func requestHandler(stream grpc....) {
  # runtime.LockOSThread()
  var decoder unsafe.Pointer
  init := false

  defer func() {
    if decoder != nil {
      C.resetDecoder(decoder)
    }
  }
  for {
    in, err := stream.Recv(); // grpc streaming
    if err != nil {
       break;
   }

   if init == true {
     C.decode(decoder, someTransformFunc(in.audio)) 
   } else {
     decoder = C.getDecoder()
     init = true
   }
  }
}

Even if I don't call runtime.LockOSThread(), it works.
but memory leak occured when repeated. 
( VmData keep increasing on /proc/{pid}/status )

If I call runtime.LockOSThread(), it works good and no memory leak.

why does a memory leak occur only when runtime.LockOSThread() is not called?



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c18dff8c-ab75-4bb3-9fed-50ecc6976be8n%40googlegroups.com.

Reply via email to