Skip to content

Huge RAM consumption on the large database #8722

Open

Description

@michael-zendaro

Version and Platform (required):

  • Binary Ninja Version: 6.1.11073-dev
  • Edition: Non-Commercial (reported as Personal)
  • OS: Arch Linux (CachyOS kernel 7.3.1-1-cachyos)
  • OS Version: rolling
  • CPU Architecture: x64 (AMD Ryzen 9 9950X3D, 16C/32T, 186 GiB RAM)

Bug Description:
Note. I generated report with AI, but it's not slop, just easier to make problem clearer with more data. Hope it's not a problem.

The main problem is the in-memory size of the database. Binary Ninja uses an astronomical amount of RAM on a large x86_64 PE binary (451 MB on disk). This may be Linux-specific (I have not tested other platforms), but the numbers are far beyond what the machine has either way.

Memory of the single binaryninja process, from /proc/<pid>/status:

State VmRSS VmSwap Total touched
Idle, analysis finished, database saved 18.6 GiB 137.5 GiB ~156 GiB
While saving the database 34.7 GiB 171.5 GiB ~206 GiB

VmPeak was 352 GiB. The process only survives because most of its memory is in swap (zram + NVMe). The .bndb itself is 14 GB on disk.

As a consequence, saving the database takes 10–20 minutes, even after insignificant changes (e.g. a single rename). CPU load is visible only while the save is running, and for most of that time Binary Ninja appears to be paging its own data back in from swap rather than writing.

Database contents:

Item Count
Functions 1,466,040
Types 2,030,113
Data variables 6,496,273
Symbols 2,693,803

Settings: analysis.mode = full, analysis.linearSweep.autorun = true.

Steps To Reproduce:

  1. Open the attached binary with default settings and let analysis finish.
  2. Apply IL2CPP metadata (names, types, prototypes) so the database reaches roughly the counts above.
  3. Save the database (.bndb, ~14 GB).
  4. Make a trivial change (rename one function) and save again.
  5. Watch VmRSS + VmSwap of the process during the save, and the time it takes.

Expected Behavior:

  • Memory use in proportion to the database (14 GB on disk), not 150–200 GiB.
  • Analysis data for functions that are not being viewed should be evictable or bounded.
  • Saving after a small change should not touch the whole in-memory state or take 10–20 minutes.

Screenshots/Video Recording:
N/A. Numbers are from /proc/<pid>/status, /proc/<pid>/smaps, free and zramctl.

Binary:
Will be uploaded via the Binary Ninja Portal; reference phrase:
I have sent it to techsupport mail, it's not too big, in zip just 7 GB.

Additional Information:

  • Types, names and prototypes were created by a third-party plugin (meta_bn_mcp, Rust): ~2.02M types, ~1.16M function names/prototypes, ~0.28M data variables. Other plugins loaded: binary_ninja_mcp.
  • That plugin also stores one large persistent view-metadata value (a 2.45 GB JSON string). It is rewritten into the database on every save and probably adds to save time, but it cannot explain 150+ GiB of memory. From its source, the plugin's own heap is estimated at a few GiB.
  • Almost all process memory is anonymous. The three largest anonymous mappings reserve 125, 79 and 36 GiB.
  • Swap during the save: zram (zstd) held 170.6 GiB of data compressed to 38 GiB, plus ~28 GiB on NVMe. Without swap the process would have been OOM-killed.
  • The binary is kinda private. So I hope you will not send it to 3rd persons. And hope it will help you to test.

Activity

  1. michael-zendaro commented on Nov 11, 2026

    @michael-zendaro
    Author

    tried 6.1.11108-dev, still huge consumption on opening, 80+ GB
    It's not peak, after it start move to the move the swap

  2. self-assigned this
    on Nov 13, 2026
  3. bdash commented on Nov 13, 2026

    @bdash
    Contributor

    I have tested this on my AMD Ryzen 9 9950X with 96GB of RAM running Ubuntu 26.04. I see memory usage, measured as the sum of VmRSS and VmSwap, peak at around 110GB when loading and reanalyzing the database. It settles back to around 80GB after that completes. During save it peaks at around 95GB. I'm not entirely sure why you're seeing higher peak memory and swap usage despite having more RAM available.

    I don't know that VmPeak is an interesting data point since it measures the size of the virtual address space mappings, which includes address space that is reserved but never touched.

    There are a couple of areas where this database reveals clear avenues for reducing memory usage:

    1. Loading holds too much in memory at once. Processing some of the larger collections incrementally can significantly reduce the highwater mark.
    2. There's not enough sharing of Type objects. The detailed annotations mean there is a lot of these, and we're not doing a good job of sharing them.

    Reducing memory use will probably improve how long it takes to save somewhat, as memory that is paged out is inherently much slower to access, but more dramatic improvements require changes to how we structure data in the database.

    That plugin also stores one large persistent view-metadata value (a 2.45 GB JSON string). It is rewritten into the database on every save and probably adds to save time.

    What plug-in is it that is doing this? A single 2.4GB JSON string doesn't sound great, let alone one that is written repeatedly.

  4. michael-zendaro commented on Nov 13, 2026

    @michael-zendaro
    Author

    About RAM, actually I wasn't clear enough, I have another programs that eats ~70GB, that's why BN starting pagination. About plugin, it's my metadata helper (purely vibecoded btw, so I clearly don't know it's consumption).
    That's why I would like for this issue take your findings, because it's more clear.
    I still think that 95 GB of ram, even for such project kinda a lot.

  5. michael-zendaro commented on Nov 13, 2026

    @michael-zendaro
    Author

    Hope this binary will help find some spots for optimization on big scale projects.

  6. bdash commented on Nov 13, 2026

    @bdash
    Contributor

    I have changes out for review that will address the two points I mentioned. They should hopefully make it into dev builds next week. With those changes in place, the peak memory usage during load and analysis on my machine drops from 110GB to around 57GB. During save memory usage still rises to around 72GB before settling back down.

  7. bdash commented on Nov 18, 2026

    @bdash
    Contributor

    Those improvements are in 6.1.11175-dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions