Search code examples
javamemory-leaksquarkusoptaplanner

Memory leak in multithreaded Optaplanner?


I seem to be getting a memory leak in Optaplanner. To reproduce, simply download the Quarkus example:

git clone https://github.com/quarkusio/quarkus-quickstarts.git
cd quarkus-quickstarts/optaplanner-quickstart

Then change src/main/resources/application.properties by increasing the termination time (e.g. to quarkus.optaplanner.solver.termination.spent-limit=10h) and uncommenting the line that says quarkus.optaplanner.solver.move-thread-count=2 to enable multithreading.

Then, run the request from the manual:

./mvnw compile quarkus:dev
curl -i -X POST http://localhost:8080/timeTable/solve -H "Content-Type:application/json" -d '{"timeslotList":[{"dayOfWeek":"MONDAY","startTime":"08:30:00","endTime":"09:30:00"},{"dayOfWeek":"MONDAY","startTime":"09:30:00","endTime":"10:30:00"}],"roomList":[{"name":"Room A"},{"name":"Room B"}],"lessonList":[{"id":1,"subject":"Math","teacher":"A. Turing","studentGroup":"9th grade"},{"id":2,"subject":"Chemistry","teacher":"M. Curie","studentGroup":"9th grade"},{"id":3,"subject":"French","teacher":"M. Curie","studentGroup":"10th grade"},{"id":4,"subject":"History","teacher":"I. Jones","studentGroup":"10th grade"}]}'

Memory usage starts steadily increasing while millions of PhreakPropagationContext objects are made. I assume this is not expected behaviour. Should I create an issue for this or am I missing something?


Solution

  • I reviewed your question, investigated the issue and ended up filing a bug. The fix is scheduled to be included in OptaPlanner 8.13.0.Final.