lap*_*ira 2 erlang mnesia elixir
你怎么读: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: []
Run Code Online (Sandbox Code Playgroud)
还打电话:
:mnesia.table_info("some_table", :size)
Run Code Online (Sandbox Code Playgroud)
它返回我16020,我认为这是键的数量,但是我怎样才能获得内存使用情况?
首先,您需要mnesia:table_info(Table, memory)获取表占用的字数,在您的示例中,您获取的是表中的项目数,而不是内存。要将值转换为 MB,您可以首先获取erlang:system_info(wordsize)机器架构的字大小(以字节为单位)(在 32 位系统上,字为 4 字节,64 位系统为 8 字节),将其乘以 Mnesia 表内存以获得大小以字节为单位,最后将值转换为兆字节,如下所示:
MnesiaMemoryMB = (mnesia:table_info("some_table", memory) * erlang:system_info(wordsize)) / (1024*1024).
Run Code Online (Sandbox Code Playgroud)