Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive memory/time usage (12GB) #1974

Closed
marcj opened this issue Jul 1, 2022 · 4 comments
Closed

Excessive memory/time usage (12GB) #1974

marcj opened this issue Jul 1, 2022 · 4 comments
Labels
bug Functionality does not match expectation

Comments

@marcj
Copy link

marcj commented Jul 1, 2022

Search terms

  • Reached heap limit Allocation failed - JavaScript heap out of memory
  • memory usage

Expected Behavior

Uses less memory

Actual Behavior

Uses too much memory

Steps to reproduce the bug

We have a project that has ~110k TypeScript LoC across 700 files and 46 packages, which takes excessive amount of memory to build typedoc docs.

  • git clone git@github.com:deepkit/deepkit-framework.git
  • cd deepkit-framework
  • npm install
  • ./node_modules/.bin/lerna bootstrap --ignore @deepkit/benchmark
  • npm run link
  • ./node_modules/.bin/tsc --build tsconfig.json
  • npm install typedoc
  • time node --max-old-space-size=12096 ./node_modules/.bin/typedoc packages/*/index.ts

To get it to work you have to increase old-space-size to something like 12GB, otherwise you get JavaScript heap out of memory.

After a while (to be precise 4:30 on M1 Max) and a substantial amount (~12GB) of memory used it generates the docs.
Screenshot 2022-07-01 at 21 11 03

Is there anything wrong with our code base where we can improve typedoc generation time?

Environment

  • Typedoc version: 0.23.2
  • TypeScript version: 4.6.3
  • Node.js version:v16.13.0
  • OS: macOS 12.4
@marcj marcj added the bug Functionality does not match expectation label Jul 1, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 1, 2022

Looking at your config, you've given TypeDoc a setup which will result in it creating 33 ts.Programs in order to run. Unfortunately, each of these is very expensive to create, and with TypeDoc's current architecture, it needs all of them in order to start running (See also: #1606)

Building TypeDoc's docs (a single ts.Program) takes ~330mb, so your memory usage sounds about right.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 1, 2022

If your monorepo can be compiled with a tsconfig.json that doesn't use project references to refer to a bunch of other tsconfig.json files, that should save a lot on time but isn't feasible for many projects...

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 6, 2022

I'm going to track this under the original #1606 issue, since it's the same root cause

@Gerrit0 Gerrit0 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2022
@marcj
Copy link
Author

marcj commented Jul 14, 2022

@Gerrit0 ok, thanks for your fast feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants