escapes to heap,use "go tool compile -m".
在 2019年8月15日星期四 UTC+8下午12:06:20,Gergely Födémesi写道:
>
>
>
> On Thu, Aug 15, 2019, 05:19 sandao >
> wrote:
>
>> In my opinion, the slice which "as" point to, is all allocated on the
>> heap in two case . so, I think the mark time should not be so differe
On Thu, Aug 15, 2019, 05:19 sandao wrote:
> In my opinion, the slice which "as" point to, is all allocated on the
> heap in two case . so, I think the mark time should not be so different.
> Can you tell me more details for you answer(when as is allocated on the
> stack, gc has a smaller task.)?
In my opinion, the slice which "as" point to, is all allocated on the heap
in two case . so, I think the mark time should not be so different. Can you
tell me more details for you answer(when as is allocated on the stack, gc
has a smaller task.)?
在 2019年8月15日星期四 UTC+8上午11:02:46,Gergely Födémes
.On Wed, Aug 14, 2019, 17:56 sandao wrote:
> type A struct {
> a int
> }
>
> func gen() []*A {
> r := make([]*A, 100)
> for i := 0; i < len(r); i++ {
> r[i] = &A{i}
> }
> return r
> }
>
> //var as []*A = gen()
>
> func main() {
>
type A struct {
a int
}
func gen() []*A {
r := make([]*A, 100)
for i := 0; i < len(r); i++ {
r[i] = &A{i}
}
return r
}
//var as []*A = gen()
func main() {
go func() {
err := http.ListenAndServe(":8034", nil)