2024-12-11 08:00:04

什么是内存堆?

什么是内存堆?


当前回答

内存堆是保存动态分配内存的常用结构。 参见维基百科上的Dynamic_memory_allocation。

还有其他结构,比如水池、堆栈和堆。

其他回答

内存组织分为两部分:堆内存和堆栈内存。

堆内存是主工作内存,最低地址是起始地址。

在堆栈内存中,数据流是由自下而上的方法驱动的。然后内存Arch被命名为stack。

它是进程使用的内存管理器从操作系统分配的内存块。然后调用malloc()等从这个堆中获取内存,而不必直接处理操作系统。

内存堆是保存动态分配内存的常用结构。 参见维基百科上的Dynamic_memory_allocation。

还有其他结构,比如水池、堆栈和堆。

堆只是一个没有任何顺序地分配或释放内存的区域。这种情况发生在使用new操作符或类似操作符创建对象时。这与按先入后出原则释放内存的堆栈相反。

A memory heap is a location in memory where memory may be allocated at random access. Unlike the stack where memory is allocated and released in a very defined order, individual data elements allocated on the heap are typically released in ways which is asynchronous from one another. Any such data element is freed when the program explicitly releases the corresponding pointer, and this may result in a fragmented heap. In opposition only data at the top (or the bottom, depending on the way the stack works) may be released, resulting in data element being freed in the reverse order they were allocated.