Open ayeshLK opened 3 months ago
In addition to the above when I import the stripe
package into another ballerina project (which only has few lines of code), and try to open it via VS Code the Ballerina VS Code plugin crashes with a similar behaviour. IMO this is a critical issue which we should fix as soon as possible.
When divide the types.bal
into multiple files [1] the LS OOM was fixed. But, when I try to locally publish this connector and use it in a Ballerina project the LS OOM still happens. The heap-dump can be found here [2]
I can see the following error notification in VS Code.
[1] - https://github.com/ballerina-platform/module-ballerinax-stripe/pull/4 [2] - https://drive.google.com/file/d/1Fj5KrrA_u9w-AHygHCZDGoANlImzjNtx/view?usp=sharing
@KavinduZoysa currently I am blocked in this issue and unable to resolve this [1] internal support ticket. Do we have any progress on this or do you guys have a workaround ?
[1] - https://github.com/wso2-enterprise/internal-support-ballerina/issues/719
@ayeshLK, still we are trying to find the root cause for this issue. Sometimes we see a GSON array with the size of 300MB-500MB and sometimes, we observe the heap is mostly allocated for the project context. Currently, we are investigating both aspects to find the exact root cause. We will update on the progress.
As a workaround, we can divide the types.bal
file into multiple files launch vs code. But if we import the same library in a different project, we are getting OOM.
In addition to what @KavinduZoysa has mentioned, we increased the memory to 2GB, and we didn't encounter the crash anymore.
I tried importing the Stripe module after building it locally and did not encounter any OOM issues. We are still investigating the OOM issue with large files and will provide updates on our progress.
When we analysed the heap dump, we identified an ArrayList with 2,927 elements (matching the number of types in the types.bal
file) as the main suspect.
After examining the JsonObjects, we observed that they contained key value pairs representing the syntax tree, as shown in the below image.
After debugging the code, we discovered that these JsonObjects were created in the Diagram.util
class. After commenting out the relevant lines and returning an empty json object instead, we no longer encountered the OOM issue, and all Language Server functionalities worked as expected.
It appears that the Diagram.util class represents every token with a JsonObject. @kanushka @hevayo
After debugging the code, we discovered that these JsonObjects were created in the
Diagram.util
class. After commenting out the relevant lines and returning an empty json object instead, we no longer encountered the OOM issue, and all Language Server functionalities worked as expected.It appears that the Diagram.util class represents every token with a JsonObject. @kanushka @hevayo
This JSON syntax tree is used to generate the Ballerina low-code diagram. I think we can deprecate this generation since the new Ballerina extension will use another LS API to generate the low-code diagram.
This JSON syntax tree is used to generate the Ballerina low-code diagram. I think we can deprecate this generation since the new Ballerina extension will use another LS API to generate the low-code diagram.
I'm sorry, we cannot deprecate this generation since we are using this functionality in a few more places.
The initial language service shutdown issue will occur due to code lens generation logic. Ballerina extension uses the getSyntaxTree
API and traverses visitors to find possible code lenses. Since the file is too bulky, getSyntaxTree
will result in an out-of-memory condition.
If we can come up with a new API to handle the code lens requirement, we will be able to remove the initial call to the getSyntaxTree
API.
However, we still need the syntax tree to work with the data mapper, service designer, and statement editor.
Description
Following error log was found in the VS Code logs:
Following heapdump was found in the project [1]
[1] - https://drive.google.com/file/d/18dKWEe9Yzu63VqpplLQK-aH1lf102Lcp/view?usp=sharing
Steps to Reproduce
Try opening the
client.bal
in the following project using VS Code.stripe_new.zip
Affected Version(s)
No response
OS, DB, other environment details and versions
No response
Related area
-> Compilation
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response