panacheentity streamall causes OutOfMemoryError: Java heap space

41 Views Asked by At
 try (Stream<Car> cars = Car.streamAll()) {
            cars.forEach(car->{
                saveCar(car);
            });
        }

problem is im streaming data with over 100k results and im getting

java.lang.OutOfMemoryError: Java heap space 

because of it

 try (Stream<Car> cars = Car.streamAll()) {
            cars.forEach(car->{
                saveCar(car);
                entityManager.detach(car);
            });
 }

this is what i have tried, but no result at all.. after like 90k results are processed it starts to slow down like for 1 processed entity per minute and then it throws outofmemoryerror

0

There are 0 best solutions below