Fixing Memory Issues in Large Excel Export and Import with Apache POI SXSSF

When building admin or B2B back-office systems, Excel download and upload are pretty much required features. In Java, Apache POI is the standard library, and at first I just implemented it with XSSFWorkbook without thinking too much. On local with a few hundred test rows, it worked fine. The problem showed up in production after real data piled up. A user clicked download for tens of thousands of rows, the screen froze for a long time, and the server crashed with OutOfMemoryError: Java heap space....

Summary of HashMap

A HashMap is a data structure that allows for finding values in constant time O(1) on average by mapping keys to indices via a hash function. Core Structure and O(1) Principles (JDK 8) A HashMap maps a key to a ‘hash code’, which then points to an array index. Array-based Access: Direct access to array indices via hash function provides O(1) performance. Collision Resolution (Chaining): If multiple keys map to the same index, they are stored in a Linked List....

Java Collections and Generics I Actually Use

When storing multiple items in Java, basic arrays have a lot of limits. Once you set the size of an array, you cannot change it, and you have to write your own code to add or remove items in the middle. That is why we use Collection. The size grows automatically, and features like adding, removing, sorting, and searching are already built in, so it is much easier to use....

Parts of this were translated using AI, so excuse any robot vibes.