Professional.JavaScript.for.Web.Developers.3rd.Edition.Jan.2012

JavaScript is a garbage-collected language, meaning that the execution environment is responsible
for managing the memory required during code execution. In languages like C and C++, keeping
track of memory usage is a principle concern and the source of many issues for developers.
JavaScript frees developers from worrying about memory management by automatically allocating
what is needed and reclaiming memory that is no longer being used. The basic idea is simple: figure
out which variables aren’t going to be used and free the memory associated with them. This process
is periodic, with the garbage collector running at specified intervals (or at predefined collection
moments in code execution).
Consider the normal life cycle of a local variable in a function. The variable comes into existence
during the execution of the function. At that time, memory is allocated on the stack (and possibly
on the heap) to provide storage space for the value. The variable is used inside the function and then
the function ends. At that point this variable is no longer needed, so its memory can be reclaimed
for later use. In this situation, it’s obvious that the variable isn’t needed, but not all situations are
as obvious. The garbage collector must keep track of which variables can and can’t be used so it
can identify likely candidates for memory reclamation. The strategy for identifying the unused
variables may differ on an implementation basis, though two strategies have traditionally been used
in browsers.
 
//局部变量只在函数执行的过程中存在。而在这个过程中,会为局部变量在栈(或堆)内存上分配相应的空间,以便存储它们的值。然后在函数中使用这些变量,直至函数执行结束。
 
 
 
 
 
 

garbage collection - 垃圾收集 生命周期 跟踪内存使用的更多相关文章

  1. PHP扩展-生命周期和内存管理

    1. PHP源码结构 PHP的内核子系统有两个,ZE(Zend Engine)和PHP Core.ZE负责将PHP脚本解析成机器码(也成为token符)后,在进程空间执行这些机器码:ZE还负责内存管理 ...

  2. JVM的内存管理、对象的生命周期、内存泄漏

    1 JVM内存 分为“堆”.“栈”和“方法区”三个区域,分别用于存储不同的数据 1.1 堆 JVM在其内存空间开辟一个称为”堆”的存储空间,这部分空间用于存储使用new关键字所创建的对象. 1.2 栈 ...

  3. BI 项目管理之生命周期跟踪和任务区域

    DW/BI 系统是复杂的实体,构建这种系统的方法必须有助于简化复杂性.13 个方框显示了构建成功的数据仓库的主要任务区域,以及这些任务之间的主要依赖关系.       在生命周期这一级可以进行多方观察 ...

  4. garbage collection - 垃圾收集

    Professional.JavaScript.for.Web.Developers.3rd.Edition.Jan.2012 JavaScript is a garbage-collected la ...

  5. Java Performance - 优化和分析Garbage Collection/垃圾收集

    随着硬件的不断提升,Java Heap 越来越大,合理的垃圾收集调优变得愈发重要.下面介绍一些最佳实践: 注意: 下面不涉及 IBM AIX Java. 同时不介绍原理,仅仅是建议以及初始配置/最佳实 ...

  6. Java Garbage Collection/垃圾收集 策略查看

    Java 的垃圾收集有各种各样的策略,默认的策略也会经常的改变. --比如到底是 serial , parallel, CMS; 具体到 Minor 怎么样,Old 又怎么样? 命令 java -XX ...

  7. Activity跳转时生命周期跟踪

    1. 步骤1(打开First Activity):经过onCreate.onStart.onResume后First Activity就展现啦: 2. 步骤2(跳转至Second Activity): ...

  8. Java垃圾回收机制(Garbage Collection)

    引用博客地址:http://www.cnblogs.com/ywl925/p/3925637.html 以下两篇博客综合描述Java垃圾回收机制 第一篇:说的比较多,但是不详细 http://www. ...

  9. Akka(2):Actor生命周期管理 - 监控和监视

    在开始讨论Akka中对Actor的生命周期管理前,我们先探讨一下所谓的Actor编程模式.对比起我们习惯的行令式(imperative)编程模式,Actor编程模式更接近现实中的应用场景和功能测试模式 ...

随机推荐

  1. 转换python脚本为可执行程序的方式

    背景: 部分工具使用python脚本编写,而目标服务器,没有安装python包,导致使用工具不方便,还需要另外安装python. 目前主要有2个主流软件,可做此类转换,把对应工具脚本转换为exe: p ...

  2. 【代码审计】CLTPHP_v5.5.3 前台任意文件上传漏洞

    0x00 环境准备 CLTPHP官网:http://www.cltphp.com 网站源码版本:CLTPHP内容管理系统5.5.3版本 程序源码下载:https://gitee.com/chichu/ ...

  3. Window关闭端口的方法(445/135/137/138/139/3389等)

    为防止漏洞被利用,需要采取必要措施,关闭以上端口,以保证系统更加安全. window2003 关闭135端口的方法 要关闭此端口,只需停止DCOM接口服务即达到目的.下面是详细操作过程. 1.打开“组 ...

  4. RF-For循环使用

    场景1:

  5. iOS开发--画一条黑色的横线

    在网上搜索了下大概有下面几种方法: 1.使用Quartz2D画出横线 需要一个UIVIew把这两个Label装起来,你需要计算好他们的位置同时给黑线预留像素的位置.这样你在UIView里面- (voi ...

  6. linux 下的爆破工具hydra

    http://www.cnblogs.com/mchina/archive/2013/01/01/2840815.html 安装手册 http://www.aldeid.com/wiki/Thc-hy ...

  7. Hadoop核心架构HDFS+MapReduce+Hbase+Hive内部机理详解

    转自:http://blog.csdn.net/iamdll/article/details/20998035 分类: 分布式 2014-03-11 10:31 156人阅读 评论(0) 收藏 举报 ...

  8. 配置React Native环境及解决运行异常

    一. 安装Homebrew: Homebrew的官网(多语言版本)简单明了地介绍了如何安装和使用这个工具,;并提供了自己的Wiki. brew的安装很简单,使用一条ruby命令即可,Mac系统上已经默 ...

  9. apk反编译看包名什么的

    首先默认你是装了java环境的 到google code里面下载apktool1.5.2.tar.bz2和apktool-install-windows-r05-ibot.tar.bz2(地址:htt ...

  10. JWNL的配置使用

    JWNL是什么? JWNL is an API for accessing WordNet-style relational dictionaries. It also provides functi ...