Problem with Fastcostmatrix


I have a little problem with the cost matrix. In my problem, I have a listener for VRP Jobs. It coult be, that a lot of calculations are made.

So for each problem I generate a new Costmatrix, new Services and new Vehicles.

My problem is, that I made some calculation before ( in my biggest example i have a costmatrix with over 300.000 elements) in the next calculation(and when I again start one of my biggest problems), the creation of the costmatrix will hold the programm and it does nothing more.
I don´t know if maybe the garbage collector of Java isn´t working so good. I just tested the creation of multiple matixes.

        FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(1000, true);            
        System.out.println("Matrix 1");
        FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder1 = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(1000, true);           
        System.out.println("Matrix 2");
        FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder2 = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(1000, true);           
        System.out.println("Matrix 3");
        FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder3 = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(1000, true);           
        System.out.println("Matrix 4");

in this round, the last print in my case was “Matrix 2”. The processor still is working and the ram usage is stoped at 1,3GB.

Sure in my problems are not used 4 matrixes in a row. But this problem seems to fit to mine with a longer time. I make calculation 1 with a big costmatrix. Then a longer time is nothing to calculate and then comes another calculation with also a big costmatrix. I think the costmatrix of the first run is flying somewhere around the programm and isn´t collected from the carbage collector. It shouldn´t be used because it is a local defined matrix.

Maybe this is not a jsprit problem just a problem with java and my IDE (i use Netbeans). Have you any hints how I can fix that?

After some tests it realy seems that the garbage collector doesn´t delete the old matrix. And the old calculation

It might be related to this:
I am about to fix this with the PR, still analysing …

yes it could be. thank you for your work :slight_smile:

1 Like

So I saw, that your fix may work and kill the problems with the memory. Now i would like to have the fix in my version of jsprit. I currently use the 1.7-RC1 dependency as you declare in the “get started” tutorial. Will the 1.7 version be updated soon? Or is it possible to use the master? I am using Netbeans with a pom.xml to add the jsprit dependency


Hi, you can always build the master for yourself (e.g. mvn clean install). If you do it with Maven, it puts the binaries into your local maven repository. Before you build it, you can also set your own version. Run your tests and if everything is fine, you can replace 1.7-RC1 with your latest build (by referencing it in your pom).
To your other question: Yes, it will be updated soon :slight_smile: (hopefully by the end of October).

Any news on the update of v 1.7-RC1 for the memory leak bug? I still didn´t update from the master because you said, it will be updated in end of oct.