erlang数据类型atom
来源:互联网 发布:香港青旅 知乎 编辑:程序博客网 时间:2024/05/19 15:41
闲来无事反看下Erlang 数据类型 atom 的结构
/*
* Atom entry.
*/
typedef struct atom {
IndexSlot slot; /* MUST BE LOCATED AT TOP OF STRUCT!!! */
Sint16 len; /* length of atom name (UTF-8 encoded) */
Sint16 latin1_chars; /* 0-255 if atom can be encoded in latin1; otherwise, -1 */
int ord0; /* ordinal value of first 3 bytes + 7 bits */
byte* name; /* name of atom */
} Atom;
typedef struct index_slot
{
HashBucket bucket;
int index;
} IndexSlot;
/*
** This bucket must be placed in top of
** every object that uses hashing!!!
** (Object*) == (Object*) &bucket
*/
typedef struct hash_bucket
{
struct hash_bucket* next; /* Next bucket */
HashValue hvalue; /* Store hash value for get, rehash */
} HashBucket;
我们能发现, 每个 atom都是被指针链接的, 进程中应尽量避免atom数量迅速增长, 否则内存会被吃尽, 暂不论gc
[{total,139362544},
{processes,19790716},
{processes_used,19790596},
{system,119571828},
{atom,24622525},
{atom_used,24604689},
{binary,27127584},
{code,22218365},
{ets,2637648}]
在增加原子一定数量后
[{total,853879208},
{processes,126928868},
{processes_used,126928668},
{system,726950340},
{atom,272067249},
{atom_used,271991932},
{binary,26969144},
{code,22218365},
{ets,2637648}]
/*
* Atom entry.
*/
typedef struct atom {
IndexSlot slot; /* MUST BE LOCATED AT TOP OF STRUCT!!! */
Sint16 len; /* length of atom name (UTF-8 encoded) */
Sint16 latin1_chars; /* 0-255 if atom can be encoded in latin1; otherwise, -1 */
int ord0; /* ordinal value of first 3 bytes + 7 bits */
byte* name; /* name of atom */
} Atom;
typedef struct index_slot
{
HashBucket bucket;
int index;
} IndexSlot;
/*
** This bucket must be placed in top of
** every object that uses hashing!!!
** (Object*) == (Object*) &bucket
*/
typedef struct hash_bucket
{
struct hash_bucket* next; /* Next bucket */
HashValue hvalue; /* Store hash value for get, rehash */
} HashBucket;
我们能发现, 每个 atom都是被指针链接的, 进程中应尽量避免atom数量迅速增长, 否则内存会被吃尽, 暂不论gc
[{total,139362544},
{processes,19790716},
{processes_used,19790596},
{system,119571828},
{atom,24622525},
{atom_used,24604689},
{binary,27127584},
{code,22218365},
{ets,2637648}]
在增加原子一定数量后
[{total,853879208},
{processes,126928868},
{processes_used,126928668},
{system,726950340},
{atom,272067249},
{atom_used,271991932},
{binary,26969144},
{code,22218365},
{ets,2637648}]
0 0
- erlang数据类型atom
- [Erlang 0028] Erlang atom
- Erlang的atom
- erlang 数据类型
- Erlang 数据类型
- 数据类型ATOM、LRESRLT
- erlang的简单数据类型
- Erlang基本数据类型
- Erlang基础 - 数据类型
- Erlang 数据类型总结
- Erlang中的数据类型
- erlang数据类型进程
- erlang数据类型转换
- erlang数据类型(1)
- erlang数据类型(2)
- erlang type convert (erlang数据类型转换)
- Erlang笔记(04) - 基本Erlang数据类型
- Erlang原子(atom)的内部实现及应用
- 编程之美:第四章 数字之趣 4.9数独知多少
- iTV android与客户端加密交互流程
- 第一篇博文
- B - 皇马
- 杭电2094产生冠军
- erlang数据类型atom
- java多线程之 ---- 线程死锁
- 用g++编译生成动态连接库*.so的方法及连接
- 基本排序方法之三——直接插入排序
- 编程之美:第四章 数字之趣 4.10数字哑谜和回文
- CSS基础-13CSS盒子模型-概述
- android动态加载类
- hdu5329(2015多校4)--Question for the Leader
- 内存泄露调试