码迷,mamicode.com
首页 > 其他好文 > 详细

Memory Region

时间:2016-07-22 06:33:57      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:

A program‘s memory usage typically includes four different regions:

  • Code -- The region where the program instructions are stored.
  • Static memory -- The region where global variables (variable defined outside any function) as well as static local variables (variables defined inside functions starting with the keyword "static") are allocated. The name "static" comes from these variables not changing (static means not changing); they are allocated once and last for the duration of a program‘s execution, their addresses staying the same.
  • The stack -- The region where a function‘s local variables are allocated during a function call. A function call adds local variables to the stack, and a return removes them, like adding and removing dishes from a pile; hence the term "stack." Because this memory is automatically allocated and deallocated, it is also called automatic memory.
  • The heap -- The region where the "new" operator allocates memory, and where the "delete" operator deallocates memory. The region is also called free store

The Following shows how them work

技术分享

技术分享

技术分享技术分享

技术分享技术分享

 

Memory Region

标签:

原文地址:http://www.cnblogs.com/klitech/p/5693758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!