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的更多相关文章

  1. C++ storage allocation + Dynamic memory allocation + setting limits + initializer list (1)

    1. 对象的空间在括号开始就已经分配,但是构造在定义对象的时候才会实现,若跳过(譬如goto),到括号结束析构会发生错误,编译会通不过. 2.初始化 1 struct X { int i ; floa ...

  2. C++ std::set

    std::set template < class T, // set::key_type/value_type class Compare = less<T>, // set::k ...

  3. C++ std::multimap

    std::multimap template < class Key, // multimap::key_type class T, // multimap::mapped_type class ...

  4. C++ std::map

    std::map template < class Key, // map::key_type class T, // map::mapped_type class Compare = less ...

  5. C++ std::list

    std::list template < class T, class Alloc = allocator > class list; List Lists are sequence co ...

  6. C++ std::forward_list

    std::forward_list template < class T, class Alloc = allocator > class forward_list; Forward li ...

  7. C++ std::deque

    std::deque template < class T, class Alloc = allocator > class deque; Double ended queue deque ...

  8. 内存管理内幕mallco及free函数实现

    原文:https://www.ibm.com/developerworks/cn/linux/l-memory/ 为什么必须管理内存 内存管理是计算机编程最为基本的领域之一.在很多脚本语言中,您不必担 ...

  9. 探测FTP状态,socket方式

    1.FTP返回码列表(哪里都能找到的): 120 Service ready in NNN minutes. 服务在NNN时间内可用 --------------------------------- ...

随机推荐

  1. C# 短信猫(SMS cat) 操作源码开发经验

    我曾经开发的某项目需要使用短信猫模块,要求使用C#编程操作.能独立使用的动态链接库之一就是网上流传的sms.dll,但它的功能较少,不能满足需求,鉴于一时找不到合适的完整代码,我深入研究了短信协议,借 ...

  2. How Old Are You?

    今天要分享的是一个测年龄的小应用,就类似是http://how-old.net官网测年龄的功能一样,我的也是这样一个功能,细节捕获当然没有how-old多啦,不过这些主要是基于一个第三方的jar包,我 ...

  3. Oracle 学习笔记2:几个入门常用命令

    oracle提供的交互方式有两种:sqlplus(命令行) sqlplusw(图形界面) 进入sqlplus方式:cmd中输入sqlplus 进入sqlplusw方式:cmd中输入sqlplusw 更 ...

  4. Git之基本命令

    先介绍一下Git: Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理.在推出后,Git在其它项目中也取得了很大成功,尤其是在Ruby社区中.目前, ...

  5. java如何准确的读取多音字

    java如何准确的读取多音字 java准确读取多音字的方法,多音字的识别一直是一个问题,笔者结合了很多不同的读取方法,完成了这个扩展的帮助类. 首先,下载java读取拼音的jar(pinyin4j-2 ...

  6. 【学习笔记】【C语言】赋值运算

    将某一数值赋给某个变量的过程,称为赋值. 1. 简单赋值 C语言规定,变量要先定义才能使用,也可以将定义和赋值在同一个语句中进行 int a = 10 + 5;的运算过程 a = b = 10;的运算 ...

  7. 15个最新加速 Web 开发的框架和工具

    我们为开发人员挑选了15个最新的 Web 开发框架,你肯定尝试一下这些新鲜的框架,有的可能略微复杂,有的提供了很多的配置选项,也有一些窗口小部件和界面交互的选择.他们将帮助你创建更优秀的网站,提供给用 ...

  8. hdu 1963 Investment 多重背包

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963 //多重背包 #include <cstdio> #include <cstr ...

  9. 解析XML文档之三:使用DOM解析

    dom解析方法是将整个xml文档装载到内存当中,然后通过树形结构方式去解析的,这种方式只适合于在pc端的开发,不是很适合手机端的开发,毕竟来说手机的内存是没法跟pc相提并论的. 具体实现步骤如下: 第 ...

  10. Codevs 1380 没有上司的舞会

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题目描述 Description Ural大学有N个职员,编号为1~N.他们有从属关系,也就是说他们的关系就 ...