rodhoward / node-sybase

23 stars 55 forks source link

Process and memory leak #35

Open Treverix opened 3 years ago

Treverix commented 3 years ago

First, thanks for that library, I use it with an electron application to connect to multiple Sybase ASE databases and it works like a charm, also with the jdbc4 driver.

I've observed a process leak. My setup closes connections after 5 mins and recreates them on demand. Each disconnect kills the java process and I expect that no processes are running after I close my application.

This is not the case. When we spawn the Java application like shown in the official example

spawn('java',["-jar",this.pathToJavaBridge, this.host, this.port, this.dbname, this.username, this.password]);

then it creates 2 processes on my WIN10 system, one for java and second one for C:\Program Files\...\java.exe. The kill now only removes the first process (java), the real process is kept alive.

I'm not sure if this is a special behavior for WIN10, but it can be avoided, if we spawn like this:

spawn(path.join(process.env.JAVA_HOME, 'bin/java.exe') ,["-jar",this.pathToJavaBridge, this.host, this.port, this.dbname, this.username, this.password]);

This, for sure, requires the env variable JAVA_HOME to be set. The solution is to give the full file path to the java executable so that only one process is created and that one is properly killed