博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Process's address space and heap
阅读量:4632 次
发布时间:2019-06-09

本文共 2151 字,大约阅读时间需要 7 分钟。

Typically, in each process, the virtual memory available to that process is called its address space. Each process's address space is typically organized in 6 sections that are illustrated in the next picture: environment section - used to store environment variables andcommand line arguments; the stack, used to store memory for function arguments, return values, and automatic variables; the heap (free store) used for dynamic allocation, two data sections (for initialized and uninitialized static and global variables) and a text section where the actual code is kept.

Heap is the area of memory in which objects with dynamic extent are allocated. The lifetime of object is greater than the lifetime of the procedure that creates it. This object is said to have dynamic extent.

The Heap

To understand why the dynamic memory allocation is time consuming let's take a closer look at what is actually happening. The memory area where new gets its blocks of memory for allocation (usually called free store or heap) is illustrated in the following picture:

When new is invoked, it starts looking for a free memory block that fits the size for your request. Supposing that such a block of memory is found, it is marked as reserved and a pointer to that location is returned. There are several algorithms to accomplish this because a compromise has to be made between scanning the whole memory for finding the smallest free block bigger than the size of your object, or returning the first one where the memory needed fits. In order to improve the speed of getting a block of memory, the free and reserved areas of memory are maintained in a data structure similar to binary trees called a heap. The various algorithms for finding free memory are beyond the scope of this article and you can find a thorough discussion about them in D. Knuth's monographThe Art of Computer Programming -- Vol.1, Fundamental Algorithms). This overhead combined with the risk for memory leaks makes the use of automatic memory (allocated on the stack) preferred whenever possible and the allocation is not large.

参考文献:

转载于:https://www.cnblogs.com/touchdown/p/5162781.html

你可能感兴趣的文章
HSSFWorkbook 与 XSSFWorkbook
查看>>
希尔排序——算法系列
查看>>
javascript ES6 新特性之 扩展运算符 三个点 ...
查看>>
Jetson tk1 安装 CUDA,ROS,OpenCV和kinect2以及刷机以及ssh远程控制
查看>>
linux 下byte,char,unsigned char的区别
查看>>
Linux内核初期内存管理---memblock(转)
查看>>
黑客第一课
查看>>
Centos7 安装 telnet 服务
查看>>
Windows Azure Virtual Network (6) 设置Azure Virtual Machine固定公网IP (Virtual IP Address, VIP) (1)...
查看>>
3.1、final、finally、 finalize
查看>>
国家气象局提供的天气预报接口
查看>>
MongoDB 删除数据库
查看>>
前端基础之JQuery
查看>>
AppStore SDK
查看>>
记录一次爬取某昵称网站的爬虫
查看>>
lattice diamond 3.7安装破解
查看>>
FPGA研发之道(25)-管脚
查看>>
BFS之三(单向bfs和康托压缩)
查看>>
Web App、Hybrid App与Native App的设计差异
查看>>
ASP.NET将原始图片按照指定尺寸等比例缩放显示图片
查看>>