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. Activity之间传递数据或数据包Bundle,传递对象,对象序列化,对象实现Parcelable接口

    package com.gaojinhua.android.activitymsg; import android.content.Intent; import android.os.Bundle; ...

  2. “尝试加载 Oracle 客户端库时引发 BadImageFormatException”的解决方案

    今天要写个程序,环境是win8.1+ vs2012+ oracle,可是却出现了一个意想不到的问题: 异常!以下为数据库提示详细错误信息:尝试加载 Oracle 客户端库时引发 BadImageFor ...

  3. UIView总结---对UIView头文件中的大部分信息进行中文注释

    @interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem> ...

  4. 推荐最近使用的一个APP

    最近使用一个APP叫做得到,觉得很不错,将一些很好的思想提炼出来,然后语音表达,放松眼睛,聆听收获.

  5. Linux概述

    Linux概述 1.计算机资源 硬件资源 软件资源 硬件资源与软件资源之间的桥梁就是操作系统 2.操作系统分类 Windows :个人版用户最多 Mac :土豪机 Linux :主要应用于服务器 Un ...

  6. C++ 11 之学习总结

    感慨时间过的好快,C++ 11出来都5年了,现在才开始学习,但为时也不晚: 主要是网上及身边的朋友大肆宣扬C++ 11的某些优化,弄得别人心里痒痒的,所以就花了3天学习了点基本知识,相对于整个C++ ...

  7. pancake的排序- 1.3 一摞烙饼的排序 《编程之美》读书笔记03

    问题:     星期五的晚上,一帮同事在希格玛大厦附近的“硬盘酒吧”多喝了几杯.程序员多喝了几杯之后谈什么呢?自然是算法问题.有个同事说:“我以前在餐馆打工,顾客经常点非常多的烙饼.店里的饼大小不一, ...

  8. BCB6中SCALERICHVIEW加入GIF动画

    记载下,花了不少时间. 1.  项目导入文件GIFImage.pas 来源:http://melander.dk/delphi/gifimage/ 2.  项目导入文件RVGifAnimate.pas ...

  9. KOBEV / KOBED

    check the highlighted. the number of execution. if too high, can be the requirement was all met. whi ...

  10. 必须知道的.NET FrameWork

    这部分内容呢,对普通开发者来说,意义不是特别大.但是作为一个有情怀的开发者,应该追根溯源,懂一些自己用的工具, 的粗浅知识.并且这部分内容可以用来个HR吹嘘一下自己的情怀.基本就是这样. .NET生成 ...