mnesia表的大小以MB为单位

问题描述 投票:2回答:2

你怎么读:mnesia.info

例如,我只有一个表,some_table,:mnesia.info返回给我。

---> Processes holding locks <--- 
---> Processes waiting for locks <--- 
---> Participant transactions <--- 
---> Coordinator transactions <---
---> Uncertain transactions <--- 
---> Active tables <--- 
some_table: with 16020    records occupying 433455   words of mem
schema         : with 2        records occupying 536      words of mem
===> System info in version "4.15.5", debug level = none <===
opt_disc. Directory "/home/ubuntu/project/Mnesia.nonode@nohost" is NOT used.
use fallback at restart = false
running db nodes   = [nonode@nohost]
stopped db nodes   = [] 
master node tables = []
remote             = []
ram_copies         = ['some_table',schema]
disc_copies        = []
disc_only_copies   = []
[{nonode@nohost,ram_copies}] = [schema,'some_table']
488017 transactions committed, 0 aborted, 0 restarted, 0 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []

同时致电:

:mnesia.table_info("some_table", :size)

它返回16020,我认为是键的数量,但我怎样才能获得内存使用?

erlang elixir mnesia
2个回答
3
投票

首先,你需要mnesia:table_info(Table, memory)来获取你的表占用的words的数量,在你的例子中,你得到的是表中的项目数,而不是内存。要将该值转换为MB,您可以首先使用erlang:system_info(wordsize)来获取机器体系结构的字节大小(在32位系统上,一个字是4字节,64位是8字节),将它乘以您的Mnesia表内存到以字节为单位获取大小,最后将值转换为MegaBytes,如:

MnesiaMemoryMB = (mnesia:table_info("some_table", memory) * erlang:system_info(wordsize)) / (1024*1024).

2
投票

您可以使用erlang:system_info(wordsize)以字节为单位获取字大小,在32位系统上,一个字是32位或4字节,在64位上是8字节。所以你的桌子正在使用433455 x wordsize。

© www.soinside.com 2019 - 2024. All rights reserved.