Fl4m3Ph03n1x

Fl4m3Ph03n1x

:memsup and BEAM memory consumption

Background

I am testing an application where I perform some actions depending on the amount of memory the machine has free. To supervise the machine’s memory I am using :memsup.get_memory_data/0 but I am getting some really weird results.

Problem

I am have a machine with 8GB of RAM, which should be more than enough for opening iex and doing some tests. However, :memsup always returns absurd results like the following:

iex(9)> {total, allocated, _worse} = :memsup.get_memory_data()
{8235098112, 7862636544, {#PID<0.118.0>, 372944}}
iex(10)> (allocated / total) * 100                             
95.47714474151489

No matter what I do, I always have :memsup report BEAM is using up to 95% of my machine’s memory. All I have open is a single session of iex that I am using as a playground.

What’s even more weird is that htop returns me a completely different value of memory usage, stating I am using 6.22GB out of 7.67GB, which still doesn’t hold up to 95% usage…

(6.22 / 7.67) * 100
81.09517601043025

Questions

So now I have some questions:

  1. Does :memsup even work?
  2. Why are the values :memsup gives me so different?
  3. Why is BEAM using over 90% of the total memory if all I have is a simple iex shell session open?
  4. Is there a reliable way to know if my machine is struggling with memory?

Marked As Solved

peerreynders

peerreynders

I wonder if the numbers seem off because total reports physical memory while allocated includes(?) cached memory.

memsup seems to be designed to pinpoint individual processes that are heavy memory users - the rest of the functionality seems to just report information reported by the OS.


You may want to look into recon (possibly via one of the Elixir wrappers) - see page 41 of Erlang in Anger

Also Liked

spencerdcarlson

spencerdcarlson

To piggy back off of this, it looks like recon_alloc:memory/1 has the answers.

:recon_alloc.memory(:usage)

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement