varsill

varsill

Membrane Core Team

Comparing memory consumption of programs run on BEAM

Hello,

I have a question concerning the comparison of memory consumption of programs run on BEAM.

Suppose that I have two versions of a program performing some computation, and I want to know which is consuming less memory. I want to have an automated testing system that runs two versions of the program multiple times in some isolated environment, measures their memory consumption during the run, and tells me which statistically uses less memory.

How should I perform the memory measurements? In particular:

  1. What method should I use to fetch the current memory usage? Would :erlang.memory(:total) be enough, or should I subtract some constant “initial” value (e.g., the amount of memory used by the BEAM before running the program)? Or perhaps it would be better, to sum up the memory used by the particular processes building my program?
  2. How often should I perform the measurement?
  3. How should I deal with the randomness of GC invocations? The results of the tests seem to be susceptible to the moment when the GC is run.
  4. How could a final metric (based on the memory measurements) look to give me a view on which version is, in fact, “better”?

I know that my question is really general, and answering it precisely requires some more specific definition of what it means that a particular program uses less memory than the other (do we take under consideration the maximum peak memory usage, or an average usage of memory, which type of memory are we interested in measuring, etc.), but I would appreciate some general tips on how such tests should be performed.

Best wishes,
Łukasz

Most Liked

LostKobrakai

LostKobrakai

Not necessarily an answer to your questions, but Benchee can perform memory usage based benchmarks.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement