-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape analysis analogy seems not correct #30554
Comments
The address of |
Thanks @randall77 . I read the slice internal doc. but still why slice is allocated in stack rather than in heap. escape analysis says it will allocate into heap. |
The backing store for the slice (the array) is allocated on the heap. The slice itself (the 3-word structure consisting of pointer to the array, a length, and a capacity) is allocated on the stack. When the escape analysis says "b escapes to heap", it means that the values in If |
Hi @randall77 , Yes you are right, address of b[0] should refer to heap address(lower address in virtual memory). but its not pointing address of i --> 0xc00007ff50 address of b[0], and b[1] --> 0xc00005a070, 0xc00005a071 my objective is that i wanna make sure that backing array is pointing to heap memory according to escape analysis. Thanks. |
Your assumption that heap addresses are lower in virtual memory is incorrect. Pages of Go heap and pages of goroutine stacks are intermingled. |
@randall77 , Thanks... that clears all my questions. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
escape analysis says that slice array b is moved to heap , but after printing the address of slice array , its address is adjacent to stack variable i address.
This is the program
https://play.golang.org/p/wGjw7wPQgu9
-->
What did you expect to see?
i expect to see the address of b should not be adjacent to stack address
What did you see instead?
The text was updated successfully, but these errors were encountered: