- Elixir Cookbook
- Paulo A Pereira
- 280字
- 2021-07-23 20:49:36
Inspecting your system in IEx
Sometimes, we need to take a look at what is going on in a running VM. It is useful to see which applications are open and any information about memory usage.
We will use some Erlang modules to inspect a VM instance.
Getting ready
Start a new IEx session.
How to do it…
We will follow these steps to get information on our running system:
- To get the currently running applications, type this:
iex(1)> :application.which_applications [ {:logger, 'logger', '0.15.1'}, {:iex, 'iex', '0.15.1'}, {:elixir, 'elixir', '0.15.1'}, {:syntax_tools, 'Syntax tools', '1.6.15'}, {:compiler, 'ERTS CXC 138 10', '5.0.1'}, {:crypto, 'CRYPTO', '3.4'}, {:stdlib, 'ERTS CXC 138 10', '2.1'}, {:kernel, 'ERTS CXC 138 10', '3.0.1'} ]
The list that is returned contains three-element tuples. The first element is an atom identifying the application, the second element is the application description, and the third is the application version.
- We get information on the memory usage by running the following commands:
iex(2)> :erlang.memory [total: 15474240, processes: 4958016, processes_used: 4957056, system: 10516224, atom: 256313, atom_used: 234423, binary: 15352, code: 6071692, ets: 399560]
- It is also possible to get memory usage for atoms, ets tables, binaries, and so on:
iex(3)> :erlang.memory(:atom) 256313
How it works…
As we saw in the previous recipe, Using Erlang from Elixir, it is possible to seamlessly call Erlang code from Elixir. Even though there is no specific Elixir code to perform these inspections, it is easy to get these abilities via Erlang libraries.
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- C語言程序設計習題解析與上機指導(第4版)
- Android Application Development Cookbook(Second Edition)
- Processing互動編程藝術
- Instant QlikView 11 Application Development
- Building a Quadcopter with Arduino
- 算法訓練營:提高篇(全彩版)
- Python編程:從入門到實踐
- Microsoft Dynamics AX 2012 R3 Financial Management
- Android應用開發深入學習實錄
- Java7程序設計入門經典
- Go語言入門經典
- Application Development with Parse using iOS SDK
- 從零開始學UI:概念解析、實戰提高、突破規則
- 輕松學Scratch 3.0 少兒編程(全彩)