Wincer

Wincer

Mnesia transaction memory is increasing

Hello everyone, I am using Mnesia to build a cacheing system, Encountered a problem:

Every time I use :mnesia.transaction, it will bring little memory consumption. Almost 10,000 :mnesia.transaction calls will consume 1MB of memory.

After some work, I found that the memory occupied by ets’s table: mnesia_transient_decision will continue to increasing. Every call to :mnesia.transaction will insert a record into table mnesia_transient_decision, and even if I use :mnesia_recover.allow_garb and :erlang.garbage_collect, the memory will not decrease. And I can’t delete this table.

Can someone help me? very appreciate

test code:

defmodule TestTransaction do
  alias :mnesia, as: Mnesia
  def init_mnesia do
    Mnesia.start()
    Mnesia.create_table(Person, attributes: [:age, :username], disc_copies: [node()])
  end
  def case_trans_read do
    f = fn ->
      Mnesia.read(Person, 2)
    end
    Mnesia.transaction(f)
  end

  def print_memory_info do
    IO.puts("total: #{:erlang.memory[:total]}, ets: #{:erlang.memory[:ets]}")
  end

  def benchmarking(_, 0), do: nil

  def benchmarking(f, n) do
    apply(TestTransaction, f, [])
    benchmarking(f, n-1)
  end

end

TestTransaction.init_mnesia

TestTransaction.benchmarking :case_trans_read, 10000

:observer_cli memory usage of ets:
|Table Name |Size | Memory |Type |Protection |KeyPos |Write/Read |Owner Pid |
|mnesia_transient_decision | 10002 | 1022.1172 KB | set | public | 2 | false/false | <0.214.0> |

First Post!

krp

krp

Saw your post yesterday and thought this was a chance to dig into a bit of mnesia. I’ve been able to reproduce this although I needed to remove the disc_copies options to get it to run. I see the same issue. Nothing added to the table but memory tied up with ets increases with each transaction call. Have you been able to figur eout the cause of this and any solution ?
Thanks

Last Post!

Wincer

Wincer

Thanks reply, this discussion is helpful, but may not solve my problem. My needs are more sensitive to memory usage…

Where Next?

Popular in Questions Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
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 55125 245
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement