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

Possible memory leak with the ANTLR Preview pane. #553

Open
KitsuneAlex opened this issue May 15, 2022 · 11 comments
Open

Possible memory leak with the ANTLR Preview pane. #553

KitsuneAlex opened this issue May 15, 2022 · 11 comments

Comments

@KitsuneAlex
Copy link

I've been using this plugin to work on my language since it's validation and visualization features are very very nice.

Since my parser has reached a certain size (~1600 lines), using the preview pane has become quite literally impossible.
It takes forever to rebuild what i suspect to be a cached pre-built parser for the current grammar, since i also suspect said
rebuild being initiated on every key-input event in the editor.. Not sure tho.

I did a little test today and found out that while using the preview pane, my JVM heap is completely used up.
I increased the maximum heap size for the IDE to 16GB, which was also used up.
I repeated the increasing until i couldn't spare any more memory on my system, which happened to be the 56GB mark (i have 64GB installed currently).

After reaching 56GB, the IDE just crashed, and i have no hs_err* file, nor another form of crash report and i'm kind of lost here,
since i am not much into IDEA-related APIs (yet).

OS: PopOS 22.04 LTS (Kernel 5.17.5-76051705-generic)
JVM: JetBrains Runtime 11.0.14.1+1-b2043.45 (amd64)
IDE: IntelliJ IDEA Ultimate 2022.1.1 (Build 221.5591.52)
Plugin Version: 1.18

@KitsuneAlex
Copy link
Author

The grammar i am working on that is causing these problems can be found here.
Keep in mind that it's still work in progress and it's gonna be subject to lot's of optimizations once it's feature complete :D

@parrt
Copy link
Member

parrt commented May 15, 2022

Hi. Yup. just fixed it!! check this one out #546 can you try to install that build? Almost ready for release.

https://github.com/antlr/intellij-plugin-v4/files/8691177/antlr-intellij-plugin-v4-1.19-SNAPSHOT.zip

@parrt
Copy link
Member

parrt commented May 15, 2022

(uninstall antlr plugin then "install from disk" that zip)

@parrt
Copy link
Member

parrt commented May 15, 2022

The first thing to check is whether or not your partner works for empty or trivial input even from the command line. I suspect there's an infinite Loop in your grammar. Make sure to check for any warning messages from antlr about empty rules

@KitsuneAlex
Copy link
Author

The memory "leak" even occurs when there's no input to parse in the preview pane, that's the odd thing.
But i forked the plugin and i'm gonna try to cut down memory usage a bit, already saw a few things.

@parrt
Copy link
Member

parrt commented May 15, 2022

so no warnings in antlr console? Try hitting the red square parse cancel button

@parrt
Copy link
Member

parrt commented May 15, 2022

Those mem objs are all from parsing gone nuts...not a leak per se.

@parrt
Copy link
Member

parrt commented May 15, 2022

Yeah, something is hosed with parsing of that grammar itself. Seems like a bug in plugin

@parrt
Copy link
Member

parrt commented May 15, 2022

Something in the grammar is causing static grammar analysis in plugin to go nuts but NOT from command line.

@parrt
Copy link
Member

parrt commented May 15, 2022

Wow. it takes ANTLR 6s on my fast box to process your parser .g4 file!!!! I have a trivial main() that exhibits...it's antlr issue not plugin :) Confirmed command line is same time.

@parrt
Copy link
Member

parrt commented May 15, 2022

@KitsuneAlex I moved issue to antlr, leaving this open... antlr/antlr4#3711

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

No branches or pull requests

2 participants