I just found that sync.Pool is almost equal to calloc/free in c language to program except that forgot call free will not cause a memory leak. I currently use sync.Pool to make the golang program use less memory. So why not just add unsafe.FreeMemory to the program. Let the programer decide to whether to manually free memory or not? My idea of unsafe.FreeMemory is working with the gc system, just tell the system to reuse the memory of a stuff before gc happen.It is not the same as https://github.com/golang/go/issues/13761 Another gain is that the runtime can auto add unsafe.FreeMemory to the result code when the compiler found that the object can be freed ealier. I guess there are reasons that `unsafe.FreeMemory` is not implement: * Garbage Collection with FreeMemory api is very difficult to implement. * `unsafe.FreeMemory` is just a source of bugs. but `sync.Pool` is also a source of bugs, they do not have any big different. * `unsafe.FreeMemory` memory reuse is not as efficient as sync.Pool.Put. * The developer of just hate calloc/free api. * add FreeMemory api to golang just make the runtime too complex.
-- 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. For more options, visit https://groups.google.com/d/optout.