Skip to content

Any way to support >4GB RAM allocations or save/load with a smaller mem footprint? #1172

Open

Description

@MikeECunningham

I've been making some irresponsibly sized worlds, trying to push into the multi-million tile mark with 16px, 256 tile levels. I can get to around 22 levels in my world grid ('save levels to separate files' ON) before loading (and, later, saving) hits a memory footprint of >4 gigabytes and the screen goes blank.

Image

This throws Error sending from webFrameMain: Error: Render frame was disposed before WebFrameMain could be accessed at s.send (node:electron/js2c/browser_init:2:86534) at _.send (node:electron/js2c/browser_init:2:72329) at BrowserWindow.<anonymous> (/tmp/.mount_ldtk.A4urIbY/resources/app.asar/assets/main.js:67:41) at BrowserWindow.emit (node:events:513:28) in my terminal window if I try to exit.

I got my own build of LDtk going with trace-gc and --max-old-space-size=16384 in all of the various locations recommended to me around the web (export to path, run with electron in package.json, WebPreferences, to name just a few) and caught OOM error in V8: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory while loading my big map, which initially had me under the impression it was Electron's V8 memory cage. After trying again with both gerhardberger's v8 sandbox disabled release, as well as multiple pre-v21 releases before V8, I am still getting the blank screen crash. Albeit, without any obvious V8-related error reports, but nevertheless always shortly after hitting the 4gig allocation point.

That's taken me to the limit of my personal familiarity with the topic. Currently neither 'save levels to separate files' nor 'multi-worlds support' offer the kind of lazy loading functionality needed to only have a portion of the project in mem at a time to lower the memory overhead while saving and loading. Is there any obvious way to beat this?

CPU: AMD Threadripper 1950x
GPU: RTX 4070
RAM: 64GB
OS: Ubuntu 25.04
Version: 1.5.3

Activity

  1. daniel-brenot commented on Jul 15, 2025

    @daniel-brenot

    If anyone feels like solving this issue, there is now a 100$ USD bounty on it.

    Bounty link here:
    https://gitpay.me/#/profile/task/1220/any-way-to-support-4-gb-ram-allocations-or-save-load-with-a-smaller-mem-footprint

  2. parvit commented on Jul 17, 2025

    @parvit

    @MikeECunningham Hi, could you share a file that triggers this behavior or some more specific steps to recreate the map?

  3. daniel-brenot commented on Jul 17, 2025

    @daniel-brenot

    @MikeECunningham Hi, could you share a file that triggers this behavior or some more specific steps to recreate the map?

    My man coming in clutch on another bounty. You rock

  4. MikeECunningham commented on Jul 18, 2025

    @MikeECunningham
    Author

    This fails to load for me on both my Ubuntu and Windows partitions.
    crasher-proj.zip

  5. MikeECunningham commented on Jul 18, 2025

    @MikeECunningham
    Author

    As concerns replication instructions, you can start up a project and scroll out in the view pane so that when you right-click a level you get the options for duplication. Then you duplicate levels, saving periodically, until you get the blank screen in the middle of saving, at which point the project will likely be too big to load again as well. You can increase how many level files you can have at once by going to the project settings tab and checking "Save levels to separate files" but that will still max out at some point as well. Keep your OS's process monitor open to the side and you'll see how the mem usage increases during saves and loads, and the crash happens shortly after you crest the 4th gigabyte.
    I'll have some time tomorrow to dig around for my work building from source with the various logs and flags, if I find it and you're interested I'll upload.

  6. parvit commented on Jul 18, 2025

    @parvit

    @MikeECunningham thanks the file does reproduce the issue on my debug build also. I'll search for the root cause now.

  7. parvit commented on Jul 18, 2025

    @parvit

    I've found the issue and it pertains to the caching of json data from the levels being loaded.
    In a quick check i've disabled that and was able to load the crasher project (its also way faster compared to before) .

    Image

    However, i think disabling this completely might not be ideal... should there be a global option to disable the caching to make it possible to load these kinds of projects? Thanks.

  8. MikeECunningham commented on Jul 18, 2025

    @MikeECunningham
    Author

    @deepnight Any input on how to proceed here? Is the caching critical?

  9. parvit commented on Jul 18, 2025

    @parvit

    Adding the option was easier than i thought so i've already prepared the PR. Please review it.

  10. self-assigned this
    on Jul 24, 2025
  11. added this to the 1.5.4 milestone on Jul 24, 2025
  12. parvit commented on Aug 5, 2025

    @parvit

    Based on the comments by @deepnight on the first PR i've sent a simpler PR without the option (but fixes the issue nonetheless).

  13. sam-gwala10 commented on Dec 18, 2025

    @sam-gwala10

    “Hi, I’d like to work on this issue and submit a PR. Can you assign it to me?”

  14. wy477wh173 commented on May 11, 2026

    @wy477wh173

    Thank you for this, I've run into this issue in the last few weeks (I don't think my project is even irresponsibly large) and lost some significant work but wasn't able to find any guidance or others experiencing the issue. I'm going to prune some levels/maps we're no longer using to reduce file size to hopefully keep me working until 1.5.4 is out.

    Is this caching something I can disable myself as a not super technical user or is this more of a "wait for 1.5.4" kinda deal?

  15. added a commit that references this issue on Aug 31, 2026
  16. GameGuyy commented on Sep 9, 2026

    @GameGuyy

    Just wanted to bump this. It fixes a renderer OOM crash on large external-level projects (#1172). Tested against the crasher project from that issue: renderer memory stays under 1GB now, where it previously blew past the ~4GB V8 heap cap and crashed before load even finished. Happy to address any review feedback.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions