[Javascript] How to solve OOM with the result of toString?

43 views
Skip to first unread message

Yuqi Pan

unread,
Sep 17, 2019, 10:14:02 PM9/17/19
to antlr-discussion
I wrote a parser for our database dialect and I want to use it to parse SQL on frontend for formatting purpose. 
But when I run it in browser:
image

I have tried the solution provided in #1854 which memorizes the result of toString(). It works for a simple SQL but failed with complex one.

Then I took a heap snapshot and found the real reason of OOM:

image


And my question is should I simplify my parser or is there any improvement for toString() method?

// PredictionContext.js
ArrayPredictionContext.prototype.toString = function() {


Here's my parse tree of following SQL:

SELECT `ename`, `deptno`, `sal`
FROM `emp`
WHERE `deptno`=(SELECT `deptno` FROM `dept` WHERE `loc`='NEW YORK');

antlr4_parse_tree_6

ML

unread,
Sep 28, 2019, 11:23:21 AM9/28/19
to antlr-discussion
Hi,

I met the similar issue, and I fixed that by changing the cache logic. Can you take a look if it works for you? 

Reply all
Reply to author
Forward
0 new messages