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时间内可用 --------------------------------- ...
随机推荐
- Python调用Webservice、访问网页
昨天在调试Webservice的时候,由于不想写测试程序,就想用Python访问Webservice,结果还是相当的麻烦.远没有VSIDE用的方便 不得不说VS还是很强大的,人性化做的很好,不需要你看 ...
- NAT
WRITE BY YANGWJ 一. 配置静态Nat 实验图如下: 1. 将网络基本条件配置好,包括路由要可达,即pc1可以ping到server1 2. ...
- iOS中调用系统录音功能及其播放
最近做的项目中,用到了录音的功能,简单记录一下. 我的想法是:通过重写button的点击事件,来达到录音的目的. /*----------------------------------[录音]--- ...
- dropdownlist值改变时调用js
DropDownList的OnSelectedIndexChanged方法是服务器端方法如要用需要设置AutoPostBack选项为true,并且在服务器后台写方法 要调用js方法需要onchange ...
- c#实现数据集合转换为csv文本
需求 1.将一个数据集合导出到一个csv文件中,集合类型可以视为 List<T>,T为任意类型,T包含多个属性,可指定部分属性进行导出 2.软件中有多种不同类型的数据类型需要进行导出 需求 ...
- MATLAB 生成 COM 步骤
环境: 操作系统:windows xp sp3 MATLAB:Version 7.1.0.246(R14) Service Pack 3 第一步:安装编译器(如果已经安装则可跳过此步) 在MATLAB ...
- PowerDesigner提示This data item is already used in a primary identifier.的处理
原文链接: http://blog.csdn.net/lopper/article/details/5293545 今天同事在编制一个数据库脚本的时候,提示了This data item is alr ...
- 遇见NodeJS:JavaScript的贵人
在大家的印象中,相当长一段时间里,JavaScript是一门脚本语言,一般不能成为某个项目的担纲主角,作用只是在浏览器里帮忙校验校验输入是不是正确,响应一下鼠标.键盘事件,或者让某个HTML元素动起来 ...
- [javascript|基本概念|Underfined]学习笔记
Underfined类型的值:underfined(只有一个) 1/声明未初始化 e.g.:var msg;-->msg == underfined:true 2/申明并值初始化为underfi ...
- daily news新闻阅读客户端应用源码(兼容iPhone和iPad)
daily news新闻阅读客户端应用源码(兼容iPhone和iPad),也是一款兼容性较好的应用,可以支iphone和ipad的阅读阅读器源码,设计风格和排列效果很不错,现在做新闻资讯客户端的朋友可 ...