Skip to content

Can >2GB database sizes be supported? #119

Closed

Description

@jlarmstrongiv

In 3.51.0

JavaScript/WASM now supports 64-bit WASM. The canonical builds continue to be 32-bit but creating one's own 64-bit build is now as simple as running "make".

It would be a big deal if databases can now go beyond the 2GB cap, though other options may need to be changed too. That would solve my biggest painpoint with the wasm version.

Browser support and Node.js support for Memory64, though the later depends on #118.

Activity

  1. sgbeal commented on Nov 12, 2025

    @sgbeal
    Collaborator

    These bindings are not limited to 2gb dbs. Emscripten, however, caps the heap at 2gb, even in 64-bit builds. When using OPFS storage, you can store much more than 2GB (but doing so is ill-advised, as OPFS is, all marketing to the contrary, transient in nature, able to be wiped at the browser's whim).

    Version 3.51 supports Emscripten 64-bit builds in all of its supported configurations. It DOES NOT support node (and will never do so without a generous long-term financial backer to cover the effort).

  2. steida commented on Nov 12, 2025

    @steida

    On both Chrome for Android and Safari for iOS (17+), installed PWAs are granted persistent or effectively persistent storage. Their OPFS data is not wiped automatically — unless the user deletes the app or the device runs critically low on space.

  3. jlarmstrongiv commented on Nov 13, 2025

    @jlarmstrongiv
    Author

    It looks like maximum memory on emscripten can be changed using MAXIMUM_MEMORY

    That could allow for a heap larger than 2gb, and hopefully larger than 4gb in 64-bit builds.

  4. sgbeal commented on Nov 13, 2025

    @sgbeal
    Collaborator

    That could allow for a heap larger than 2gb, and hopefully emscripten-core/emscripten#19512 than 4gb in 64-bit builds.

    It could, i guess, but we don't distribute 64-bit builds and, after a team discussion, have no immediate plans to. You're welcome to build one with only a tiny makefile tweak to see MAXIMUM_MEMORY, but if you're using the npm then you're presumably not building your own.

    On both Chrome for Android and Safari for iOS (17+), installed PWAs are granted persistent or effectively persistent storage. Their OPFS data is not wiped automatically — unless the user deletes the app or the device runs critically low on space.

    Installed PWAs represent a diminishingly small subset of OPFS clients. For every other client, a browser update and/or hiccup can cause OPFS to be wiped.

  5. jlarmstrongiv commented on Nov 13, 2025

    @jlarmstrongiv
    Author

    If the team considers distributing 64-bit builds in the future, I think that would be a good opportunity to look into increasing the MAXIMUM_MEMORY to support larger database files too.

    It seems the maximum limit for the JS API is 16gb.

    I think it’d be worth revisiting in the future when Safari adds support for Memory64.

    It could, i guess, but we don't distribute 64-bit builds and, after a team discussion, have no immediate plans to. You're welcome to build one with only a tiny makefile tweak to see MAXIMUM_MEMORY, but if you're using the npm then you're presumably not building your own.

    I hope it’s just a tiny tweak. Unfortunately, attempts to increase the memory of other wasm libraries haven’t been so easy.

  6. sgbeal commented on Nov 13, 2025

    @sgbeal
    Collaborator

    If the team considers distributing 64-bit builds in the future, I think that would be a good opportunity to look into increasing the MAXIMUM_MEMORY to support larger database files too.

    The build already supports them and we recently spent about a week straightening out the breakage caused by the differing JS-side pointer types between the two1. We've discussed distributing 64-bit builds with the canonical downloads but it's a solution looking for a problem: we're not aware of anyone aching to make 64-bit-only browser-side deployments.

    I hope it’s just a tiny tweak. Unfortunately, attempts to increase the memory of other wasm libraries haven’t been so easy.

    It really is, but it's a build-time option, not runtime option. Search the makefile for emcc.jsflags and add yours to it. Some flags are set via generated code. The ones set in that makefile apply to all of the builds.

    Then just make. See the README in that dir for the full build details.

    Footnotes

    1. It's actually easier to write 32/64-bit-portable code in C than in JS because in JS the change breaks all pointer math: https://github.com/emscripten-core/emscripten/discussions/25341 ↩

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

Metadata

Metadata

Assignees

No one assigned

    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