tcoopman
I’m trying to debug a strange jump in memory that I can’t seem to place why it happens.
I’m using live_view and one page I have a jump in memory from 150MB to over 500MB, and it only happens on one page.
Here you can see the screenshot from the LiveDashboard
The problem I have, how do I figure out what triggers this jump in memory? What tools can I use to figure this out?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming












Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
garrison
Not really an answer to your question but I was curious where those values in the chart actually come from. It appears to be this call to
:erlang.system_info({:allocator_sizes, _}).Still not clear to me what the values actually mean, though. The docs for
system_info/1imply it’s intentionally undocumented.Samjowen
On the problem page, what kind of work is it doing? It might give us some more insight.
garrison
Oh never mind, here they are. Which one is spiking in the chart? Those colors are unfortunately not very distinguishable.
tcoopman
It’s the driver allocator line, not sure what that means?
I have been able to find the call that blows up the memory, but I don’t understand what’s going on.
I have a stream that reads stuff from the database with sqlite. It’s one big table with events. The events have a stream_id.
Reading most kinds of stream_ids doesn’t increase the memory at all.
But one type of stream_id blows up the memory even if I only read one row.
I’m on my phone now, can post more details later.
LostKobrakai
You can use the instrument — OTP 29.0.2 (runtime_tools 2.4) module to get more information on the memory stored. This kind of tracking is enabled by default for the binary_* and driver_alloc. Given this is sqlite it’s likely some NIF related data. I also seem to remember that driver_alloc is about NIF memory.
tcoopman
Ok, I haven’t been able to use instrument yet, but I do have some interesting observations.
I’ve been able to pin it down to a specific query that when I run it with
Ecto.Adapters.SQL.query!triggers the memory blowout. (I used the raw sql query to make sure it wasn’t because of the use of dynamic).The strange/weird thing is that if I run exactly the same query directly against exqlite then the memory stays normal…
I was under the impression that
ecto_sqlite3usesexqliteso I wasn’t expecting this..Btw, this is the query:
sqlSELECTs0.“id”,e1.“id”,e1.“type”,e1.“data”,e1.“inserted_at”,s0.“stream_id”,s0.“stream_version”FROM “stream_events” AS s0INNER JOIN “events” AS e1 ON s0.“event_id” = e1.“id”WHERE s0.“stream_id” = ‘$all’ AND s0.“stream_version” >= 0ORDER BY s0.“id” DESCLIMIT 1Some other observations:
DESCtoASCI don’t have the issueDoes anyone have any thoughts on what my next steps could look like?
tcoopman
I had a look at instrument. But I have no idea how to use this or interpret the numbers that come out of it.
Is this meant to be used with a tool that creates more useful insights?
tcoopman
I’ve been able to figure out how to use
instrument. For future references. Run a script like this to get the best information out:elixir --erl “+Muatags true” sqlite_reproduction.exsSo I ran
:instrument.allocationsbefore the query and after the query, and thse are the only significant changes that I see:So this line:
nif_internal: {1999, 438, 40, 10, 10, 9, 15474, 0, 0, 10, 10, 1, 0, 0, 0,0, 0, 0}Running with
exqlitegives me no such thing:For completeness here is the full script that I used:
NickGnd
Hey
a bit late to the party, but in the past I happily used recon for discovering which process was greedy of memory.
Check out
proc_countfunction.For instance, you can do something like that:
```
Good luck
dimitarvp
My SQLite library does streams quite well and I am about to announce it here on ElixirForum. I have not yet tested it with millions of records (suggestion of an open dataset that has as many? I am willing to test with it) but all of my tests have shown a stable memory load so far.
Were you able to progress further since the last time you posted?