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. 深入浅出ExtJS 第三章 表格控件

    3.1 表格的特性简介 >.Ext中的表格功能:包括排序/缓存/拖动/隐藏某一列/自动显示行号/列汇总/单元格编辑等实用功能; >.表格由类Ext.grid.GridPanel定义,继承自 ...

  2. jquery实现简单的ajax

    -->html页 1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "htt ...

  3. [老老实实学WCF] 第六篇 元数据交换

    老老实实学WCF 第六篇 元数据交换 通过前两篇的学习,我们了解了WCF通信的一些基本原理,我们知道,WCF服务端和客户端通过共享元数据(包括服务协定.服务器终结点信息)在两个 终结点上建立通道从而进 ...

  4. 6个超炫酷的HTML5电子书翻页动画

    相信大家一定遇到过一些电子书网站,我们可以通过像看书一样翻页来浏览电子书的内容.今天我们要分享的HTML5应用跟电子书翻页有关,我们精选出来的6个电子书翻页动画都非常炫酷,而且都提供源码下载,有需要的 ...

  5. Excel 窗体控件属性

    常规 AutoLoad   (Excel) 打开工作簿时是否加载控件.(如果是 ActiveX   控件,则忽略.) Enabled(表单) 控件是否可以接收焦点并响应用户生成的事件. Locked( ...

  6. 数据库连接字符串大全 资料引用:http://www.knowsky.com/339545.html

    转自:http://www.connectionstrings.com/ • SQL Server • ODBC ◦ Standard Security: "Driver={SQL Serv ...

  7. 20130909QA整理笔记

    做项目里遇到的一些问题!! 1.滚动条样式 webkit可以使用css来调节滚动条样式: http://www.cnblogs.com/rubylouvre/archive/2011/03/01/19 ...

  8. javascript代码复用--继承

    由于javascript没有类的概念,因此无法通过接口继承,只能通过实现继承.实现继承是继承实际的方法,javascript中主要是依靠原型链要实现. 原型链继承 原型链继承是基本的继承模式,其本质是 ...

  9. Shell脚本升级CentOS php版本v

    #! /bin/sh #1.关闭selinuxcp -rp /etc/selinux/config /etc/selinux/config.baksetenforce 0sed -i '7s/enfo ...

  10. WPF 绑定二(绑定指定的字符串)

    xaml: <Window x:Class="WpfApplication1.Window2" xmlns="http://schemas.microsoft.co ...