Skip to content

Large Result Not Chunked (ARCH4062)

Key java.orm.large-result-not-chunked · Severity info · Category orm

Loading a large result set fully into memory and iterating it exhausts memory at millions of rows. Use a streaming/chunked cursor.

List<Log> logs = logRepository.findAll(); // all in memory
for (Log log : logs) {
archive(log);
}
try (Stream<Log> logs = logRepository.streamAll()) {
logs.forEach(this::archive); // row-by-row stream
}

Process large results with a Stream/chunked cursor instead of loading them all at once.