Skip to content

Commit

Permalink
fix: jdtls out of heap space error
Browse files Browse the repository at this point in the history
  • Loading branch information
bhoopesh369 committed Jan 14, 2024
1 parent 6abbe8e commit eb28a5e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions controllers/file.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package controllers

import (
"io/ioutil"
"os"
"path/filepath"

"github.com/delta/codecharacter-lsp-2023/models"
)

func handleFileUpdate(message map[string]interface{}, ws *models.WebsocketConnection) error {
filename := "player" + ws.Language.GetExtension()
return ioutil.WriteFile(ws.WorkspacePath+"/"+filename, []byte(message["code"].(string)), 0644)
return os.WriteFile(ws.WorkspacePath+"/"+filename, []byte(message["code"].(string)), 0644)
}

func getAbsPath(ws *models.WebsocketConnection) error {
Expand Down
4 changes: 2 additions & 2 deletions servers/ccls.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package servers

import (
"fmt"
"io/ioutil"
"os"
"os/exec"

"github.com/delta/codecharacter-lsp-2023/models"
)

func createCppServer(ws *models.WebsocketConnection) error {
filename := "compile_commands.json"
err := ioutil.WriteFile(ws.WorkspacePath+"/"+filename, []byte(createCompileCommands(ws)), 0644)
err := os.WriteFile(ws.WorkspacePath+"/"+filename, []byte(createCompileCommands(ws)), 0644)
if err != nil {
return err
}
Expand Down
8 changes: 5 additions & 3 deletions servers/jdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (
)

func createJavaServer(ws *models.WebsocketConnection) error {
workspaceDir, _ := filepath.Abs(ws.WorkspacePath)
workspaceDir, err := filepath.Abs(ws.WorkspacePath)
if err != nil {
return err
}
ws.LSPServer.Process = exec.Command("java",
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
"-Dlog.level=ERROR",
"-noverify",
"-Xmx100M",
"-Xmx512M",
"-jar",
"/jdt/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar",
"-configuration",
Expand Down
4 changes: 4 additions & 0 deletions utils/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func dropConnection(ws *models.WebsocketConnection, c echo.Context) {
err := ws.LSPServer.Process.Process.Signal(os.Interrupt)
if err != nil {
c.Echo().Logger.Error(err)
err = ws.LSPServer.Process.Process.Signal(os.Kill)
if err != nil {
c.Echo().Logger.Error(err)
}
}
_ = ws.LSPServer.DevNullFd.Close()
// Reads process exit state to remove the <defunct> process from the system process table
Expand Down

0 comments on commit eb28a5e

Please sign in to comment.