Thank you for the clarification. sorry to break the general rule, i'm new to golang-nuts
as to the question, i figured out i used wrong words, what i need in fact is1. a hint to tell compiler that some object are safe to alloc on stack(in case that we use it as interface so it escape from stack) 2. some concept like unique ptr that when it end it's life time, the object referenced can be deallocated immediately. sorry to disturb you, and thanks for answer my question On Fri, May 28, 2021 at 1:55 PM Kurtis Rader <kra...@skepticism.us> wrote: > On Thu, May 27, 2021 at 10:36 PM cheng dong <qq451954...@gmail.com> wrote: > >> ok, i realized that it is unrealistic to add free operation in go. >> i think i lack some knowledge of how gc works. may i have a question, if >> it is obvious to go compiler when a object got no reference why go only >> collect memory in gc steps instead of collect immediately after object got >> no reference? >> > > You only replied to me, not the golang-nuts mailing list. As a general > rule you should not do that. > > If it is obvious to the Go compiler "a object got no reference" the > compiler will place the object on the goroutine stack rather than in the > heap. Assuming, of course, that the object has a size reasonable for > placement on the stack. Therefore not requiring the intervention of the Go > garbage collector. > -- 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/CACh3t4kDf_kG%3D7FYqhjYCFdHU0JhNPBimVbOyLodP7ocLQz4fw%40mail.gmail.com.