Dynamic Memory Allocation

Asked 2 years ago, Updated 2 years ago, 26 views

It's a function called "free" that makes a memory alloc.

But as a factor, you only get one pointer, how much dynamic allocation is there They didn't hand over the size, so how do you know how much dynamic allocation they're going to release?

c

2022-09-22 18:24

1 Answers

https://stackoverflow.com/a/1957125/9437175

You can refer to the link above, and when you allocate memory, you can allocate a little more spare memory to store additional information about that memory, so you can see the size.

When memory is allocated, additional information is stored as part of a data structure maintained by the heap manager. This information includes, among other things, the block’s size, and is typically placed immediately adjacent to the allocated block.


2022-09-22 18:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.