JetBrains / markdown

Markdown parser written in kotlin
Apache License 2.0
682 stars 75 forks source link

Markdown makes huge amount of memory allocations during indexing #120

Open piotrtomiak opened 1 year ago

piotrtomiak commented 1 year ago

The LookaheadText.testFromPosition depends on String.subSequence which actually copies the content over to a new array:

ultimate – LookaheadText kt  jetbrains markdown  2023-05-18 21-17-40

As a result during 15s of indexing, even 1.7GB of data can be allocated. You can check it out by profiling indexing of https://github.com/JetBrains/ring-ui/tree/master in WebStorm.

It seems that it would be best to use something similar to com.intellij.util.text.CharSequenceSubSequence to save a lot on memory allocations.

piotrtomiak commented 1 year ago

https://youtrack.jetbrains.com/issue/IDEA-320694