About the Storage allocation
It doesn't matter what programming language u use,it's all about the usage of variable---storage management.
1.Static & Dynamic
static: Global constants and the other information/data generated by compiler are allocated static storage. Static storage is built before any execution,and they would stay in memory throughout execution.
Advantage: use for public /global generally; instance object with the same class share static data/function
Disadvantage:can't be changed(lack of flexibility);static function can't manipulate non-static variables
dynamic: storage can be allocated when program is ruuning.
2.Heap
Within programming, if u need to get any storage,u can "new"/"malloc",but at the end of program,u have better "delete"/"free" these storage,only in this way could the program be secure(e.g. no memory leak). From above,we would know that the size of heap can't be detemined by one time generally.
advantage:dynamic storage management
disvadvantage:unsecure(forget to "delete /free"),ineffiency
3.Stack
Any information about local variables,parameters,state,etc. are allocated space on a stack,the same to heap ,its size can't be determined by compile time
advantage: support the recursion
disadvantage: inffiency(indirect addressing)
PS:文中若出现语法错误,请见谅并指出,大家可互相学习
About the Storage allocation的更多相关文章
- C++ storage allocation + Dynamic memory allocation + setting limits + initializer list (1)
1. 对象的空间在括号开始就已经分配,但是构造在定义对象的时候才会实现,若跳过(譬如goto),到括号结束析构会发生错误,编译会通不过. 2.初始化 1 struct X { int i ; floa ...
- C++ std::set
std::set template < class T, // set::key_type/value_type class Compare = less<T>, // set::k ...
- C++ std::multimap
std::multimap template < class Key, // multimap::key_type class T, // multimap::mapped_type class ...
- C++ std::map
std::map template < class Key, // map::key_type class T, // map::mapped_type class Compare = less ...
- C++ std::list
std::list template < class T, class Alloc = allocator > class list; List Lists are sequence co ...
- C++ std::forward_list
std::forward_list template < class T, class Alloc = allocator > class forward_list; Forward li ...
- C++ std::deque
std::deque template < class T, class Alloc = allocator > class deque; Double ended queue deque ...
- 内存管理内幕mallco及free函数实现
原文:https://www.ibm.com/developerworks/cn/linux/l-memory/ 为什么必须管理内存 内存管理是计算机编程最为基本的领域之一.在很多脚本语言中,您不必担 ...
- 探测FTP状态,socket方式
1.FTP返回码列表(哪里都能找到的): 120 Service ready in NNN minutes. 服务在NNN时间内可用 --------------------------------- ...
随机推荐
- 【CSS3】---层模型position之fixed固定定位、absolute绝对定位和relative相对定位
什么是层模型? 什么是层布局模型?层布局模型就像是图像软件PhotoShop中非常流行的图层编辑功能一样,每个图层能够精确定位操作,但在网页设计领域,由于网页大小的活动性,层布局没能受到热捧.但是在网 ...
- 二维码zxing源码分析(一)camera部分
首先,我们先把zxing的源代码给下载下来,这个网上有很多,我下载的是2.3的,不得不说这个谷歌提供的包包含的功能还是很全面的. 我把下载的包解压后,找到android文件夹,导入到ecpli ...
- Android之开源项目工具库篇
本文转自:http://www.trinea.cn/android/android-open-source-projects-dev-lib/ 本文中你可以找到那些精美App中各种有特性的View,如 ...
- 001.android初级篇之ToolBar
官方的最新support library v7中提供了新的组件ToolBar,用来替代之前的ActionBar,实现更为弹性的设计在 material design 也对之做了名称的定义:App ba ...
- Cocos2d-js中Chipmunk引擎
我们先介绍轻量级的物理引擎——Chipmunk.Chipmunk物理引擎,由Howling Moon Software的Scott Lebcke开发,用纯C编写.Chipmunk的下载地址是http: ...
- Quartz 第六课 CronTrigger(官方文档翻译)
CronTriggers使用的频率比SimpleTrigger跟高.如果需要schedule 中触发Job的方式类似于日历的形式而不是一个确定的是时间间隔,那就需要使用CronTrigger. 对于C ...
- Python的functools.reduce用法
python 3.0以后, reduce已经不在built-in function里了, 要用它就得from functools import reduce. reduce的用法 reduce(fun ...
- linux交叉编译裁剪内核记录
刚开始学习嵌入式内核编译,因为要修改内核的默认配置,因此这里把自己的学习记录写下来,方便以后查阅,也给别人一个参考,有什么写的不对的或者更好的方法,请指正~ 开发板有usb从口,现在想要让开发板作为一 ...
- MYSQL序言
我写MYSQL的文章主要的原因:我发现网上关于MYSQL的文章比较少,而且很多都是参差不齐,几乎找不到可以比较全面的介绍:例如一篇文章介绍如何增删改查,却没有介绍批量新增:于是下次工作中用到的时候又要 ...
- js中字符和数组一些基本算法题
最近在刷 fcc的题,跟升级打怪一样,一关一关的过,还挺吸引我的.今天抽时间把 Basic Algorithm Scritping 这部分题做了,根据一些提示,还是比较简单的.有些题的处理方式 方法 ...