Iulian
09/22/2026, 9:09 AMkapa.ai
09/22/2026, 9:09 AMIulian
09/22/2026, 9:10 AMkapa.ai
09/22/2026, 9:10 AMMongodbRecordConsumer loads all documents from the temporary collection into an in-memory list before copying them to the permanent collection without batching, which exhausts the Java heap space when dealing with large volumes of data [MongodbRecordConsumer.java; destination-mongodb issue].
Based on the provided documentation and community discussions, here are the approaches users have explored when encountering memory crashes of this type:
1. Increase Container Memory Limits and JVM Heap You can allocate more memory to the connector containers to accommodate the large in-memory list:
⢠Connection-level resource settings (Kubernetes / Database): Users update the resource_requirements column directly on the connection table in the Airbyte database [Java heapspace issue; destination-s3-data-lake issue]:UPDATE connection
SET resource_requirements = '{"memory_limit": "20Gi", "memory_request": "2Gi"}'
WHERE id = 'your-connection-id';
⢠Environment variables: In Docker Compose .env or Helm values.yaml, increase job container limits [Forum Post: How to specify CPU,MEMORY limit in .env; Java heapspace issue]:JOB_MAIN_CONTAINER_MEMORY_REQUEST=4g
JOB_MAIN_CONTAINER_MEMORY_LIMIT=8g
⢠JVM Options: In Kubernetes environments, configure JAVA_OPTS to allow the JVM to utilize the container's RAM [Java heapspace issue]JAVA OPTS "-XX:+ExitOnOutOfMemoryError -XX:MaxRAMPercentage=80.0 -XX:+UseG1GC"_(Note: As reported in related issues, simply increasing memory may delay the crash rather than prevent it if data volumes significantly exceed available RAM [Forum Post: Destination MongoDB: unexpected high memory usage; destination-s3-data-lake issue].)_
2. Community Proposed Fix (Custom Connector Build) In the open issue, a community contributor proposed updating copyTable in MongodbRecordConsumer.java to iterate over a cursor and write in batches (such as batches of 1,000 documents) instead of attempting to copy everything at once [destination-mongodb issue]:
private static void copyTable(final MongoDatabase mongoDatabase, final String collectionName, final String tmpCollectionName) {
final var tempCollection = mongoDatabase.getOrCreateNewCollection(tmpCollectionName);
final var collection = mongoDatabase.getOrCreateNewCollection(collectionName);
final int BATCH_SIZE = 1000;
final List<Document> batch = new ArrayList<>();
try (final MongoCursor<Document> cursor = tempCollection.find().projection(excludeId()).iterator()) {
while (cursor.hasNext()) {
batch.add(cursor.next());
if (batch.size() == BATCH_SIZE) {
collection.insertMany(new ArrayList<>(batch));
batch.clear();
}
}
if (!batch.isEmpty()) {
collection.insertMany(batch);
}
}
}
If you manage your own deployment and can build custom connector images, patching this method locally is the primary workaround suggested in the issue discussion [destination-mongodb issue]. š 0 button š 0 button ā¹ļø Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.