mathjax / mathjax/MathJax

Memory leak when linking to MathJax directly

Open
#3,591 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Accepted Investigate v4
Dominant language
JavaScript
Stars
10.9k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Issue Summary

I am using a fork of rehype-mathjax which upgrades from v3 to v4, in a project containing approximately 1,900 markdown files, the majority of which contains maths. Recently the build has been surpassing 4 GB of memory usage on my personal machine, and MathJax seems to be the culprit, as disabling it removes the memory leak.

Steps to Reproduce:

Run pnpm build on the project linked above.

I know this can hardly be considered a “minimal” reproduction, but this bug obviously requires a substantial number of files to reproduce. If there is something else you would like me to try, please let me know.

For what its worth, the rehype-mathjax fork follows the approach of linking to MathJax directly. Unfortunately my PR to remark-math has been open for 5 months with no response.

Technical details:
  • MathJax/src Version: 4.1.3
  • OS: 26.5.1
  • Node: 24.7.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running pnpm build in the linked project with MathJax enabled, then compare memory usage with MathJax disabled. Focus on the direct-linking approach described in the MathJax server documentation and verify that processing the large markdown collection no longer grows beyond the reported 4 GB usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.