首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> 专家专栏 >> Symbian翻译小组 >> Symbian OS SDK V8.1a >> Symbian OS guide >> Base >> Using User Library >> Memory Management >> concepts >> 正文
Heaps
作者:LeeFj    文章来源:http://www.nbszyy.com.cn/blog/default.asp    更新时间:2005-12-9 10:51:29


                  Symbian sdk帮助-Heaps
               译文作者: Leefj
  译文版本:1.0   译文时间:2005-12-9

 

Heaps

Each thread has a chunk which contains that thread's program stack. For the main thread of a process, this chunk also contains the thread's heap. A program's request for memory is allocated from this heap. For example, a code fragment such as:

每一个线程都有一个包含了自身程序栈(program stack)的chunk。对于进程的主线程来说,这个chunk中同样也包含了线程heap。程序对于内存的请求都是从这个heap的地址空间来分配的,例如有以下代码:

 

CArrayFixFlat<...>* fixflat;

...

fixflat = new (ELeave) CArrayFixFlat<...>(3);

 

causes a portion of memory to be allocated from the heap and its address returned to the caller. Memory from the heap must be explicitly requested and, importantly, explicitly freed by the program.

 

程序请求了heap中部分的内存地址,并把地址返回给调用者。请求heap中的内存必须是显式的,同样,释放这些内存时也必须进行显式调用。

 

If a process creates additional threads, then a new chunk is created for each new thread. Each chunk contains the thread's stack; if a new thread is not sharing an existing heap, then the chunk also contains a new heap.

如果进程创建了另外的线程,那么每个新线程都被创建一个新的chunk。每个chunk都包括了线程栈;如果新的线程没有共享到一个已经存在的heap(堆),那么chunk同样包含了一个新的heap。

 

When a new thread is created, either:

当一个线程被创建,以下情况的一个将会出现

a new heap is created for it ,it uses the creating thread's heap

创建一个heap,线程使用这个新建的heap。

 

it uses an explicitly referenced heap.

线程使用一个显式引用的heap。

 

A thread gets the handle to its heap by calling User::Heap().

线程使用User::Heap()获得它的heap的句柄。

 

相关文章:
线程与进程的优先级
线程的终止
线程赋值的相对优先级
线程的绝对优先级别
进程与线程简介
线程和进程 ID
异常处理
堆结构
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号