Chentai-Kao / codemap-public

18 stars 0 forks source link

Error loading graph: Cannot enlarge memory arrays #12

Open TravisDart opened 3 years ago

TravisDart commented 3 years ago

I tried to load a big repo into Codemap, but it looks like it ran out of memory. How do I fix this? Screen Shot 2021-10-22 at 7 49 06 AM

feuGeneA commented 2 years ago

I encountered this too. It triggered the OOM-killer on my system, which took out my web browser process. :roll_eyes: I was trying to run it against a checkout of https://github.com/nomiclabs/hardhat

john-landgrave commented 2 years ago

This is definitely still an issue. I totally get that the product is $12/year (and appreciate what that means in terms of dev effort that can be committed to it) but this type of thing would actually kick ass for onboarding new devs and particularly reasoning about very large projects. Unfortunately, this bug is a show-stopper for very large projects. I'm assuming (based on the error) that at least some of the following are true:

  1. There is an underlying binary that has already been compiled and therefore this can't be a "configured at runtime" thing.
  2. Compiling with ALLOW_MEMORY_GROWTH prevents some optimizations that make the program usable.
  3. Module.TOTAL_MEMORY isn't something that can be configured at runtime

If 1 and either 2 or 3 are false, seems like a pretty easy (albeit a "there be dragons") option to add to the product? Obviously, this is not an open-source product, but I would be happy to have either me or someone on my team tackle this, if you want?

Chentai-Kao commented 2 years ago

Sorry about the OOM problem. This is because Codemap runs on Electron JS, which is a chromium browser under the hood. This error could happen in 3 areas:

  1. when the language parser parses the source code. ---> seems possible to configure memory size
  2. when the visualizer arrange the parsed code into a 2D layout. ---> impossible to tweak
  3. when the chromium browser renders the layout on the screen. ---> impossible to tweak unless re-compiling the underlying chromium browser

I thought about providing configurable memory settings, but then realized that, even if there's no OOM error, the UI will be unresponsive with > 500 nodes that's is equally unusable. Therefore, among the top 3 areas, the 3rd area is the bottleneck.

Electron JS was used so I can quickly distribute this to multiple platforms with limited dev efforts. Given the above 3 places where OOM error may occur, I think the only way forward is one of the following:

  1. Figure out a way to work around the 3 limitations above. Any Electron expert that could give me a hand?
  2. Replace Electron with a native app, with rending done by Java or QT. I assume it will solve the memory problem in the UI layer, which then makes solving for language parser and visualizer more meaningful.

What do you think?

P.S. I tried visualizing the hardhat repo mentioned by @feuGeneA above, with ~50 files and ~250 functions. It turns out to be fine. Maybe try not to visualize the whole repo at once?

screenshot_20220416_230055

Chentai-Kao commented 1 year ago

Hi y'all, I've released a new version of Codemap that visualizes within your default browser (not Electron), so now the memory limit is bounded by your browser, but hopefully that's better. Could you try out the new app at https://codemap.app/? Thanks.