One way to ensure that Box::new() actually allocates memory on the heap is to check the address of the value returned by Box::into_raw(). If the address is within a certain range (which varies depending on the platform), then it is very likely that the memory was allocated on the heap. Another way is to use a memory profiler or a tool like Valgrind to verify that memory is being allocated on the heap. Additionally, the Rust documentation for Box::new() states that it "allocates memory with the global allocator" which is typically the heap, so it is generally safe to assume that memory is being allocated on the heap.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-04-11 11:00:00 +0000
Seen: 9 times
Last updated: Oct 24 '22
What are the Cordapp Certificates used for in terms of signing and interacting?
How can SSL be used with CqlSessionFactoryBean in Springboot Cassandra?
How to set up Database First configuration in Entity Framework 7 for MVC 6?
How can I address the issue of Content Security Policy blocking more than I had anticipated?
How do I resolve a 502 error when attempting to call an HTTPS REST API from an HTTP REST API?
What does borrowing or moving a value from `stdout` mean?