You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by "hubeoo (via GitHub)" <gi...@apache.org> on 2024/06/11 15:36:39 UTC

Re: [I] function StringToBytesWithNoCopy(s string) in pkg/util/util.go have some problems in GC scenarios [servicecomb-service-center]

hubeoo commented on issue #1432:
URL: https://github.com/apache/servicecomb-service-center/issues/1432#issuecomment-2161068537

   reflect.StringHeader is unsafe
   ```
   type StringHeader struct {
   	Data uintptr
   	Len  int
   }
   ```
   Garbage Collector (GC) : Go's garbage collector automatically tracks all valid Pointers to ensure that the memory they point to is not reclaimed. This means that as long as there is a valid pointer to a memory region, that memory region will not be collected by the garbage collector.
   
   **_StringHeader_** which uses _**uintptr**_  is a typeless integer that can be used to hold pointer values, but it is not really a pointer type. Therefore, the garbage collector will not regard _**uintptr**_  as a valid pointer to track. Causes StringHeader to be affected.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org