Skip to content

Conversation

@aaron-seq
Copy link

Fixes critical memory leak in DefaultWriter.uploadBulk0() method when exceptions occur during bulk upload preparation. ByteBuf objects were not being properly released in exception scenarios.

Fixes #2938

…dling

The uploadBulk0() method had a critical memory leak when exceptions occurred
during bulk upload preparation. ByteBuf objects allocated for dataBuffer
and objectBuffer were not being properly released in exception scenarios,
causing OutOfDirectMemoryError under high load with network instability.

Changes:
- Added proper ByteBuf cleanup in catch block for both dataBuffer and objectBuffer
- Implemented defensive cleanup with null checks and exception safety
- Added comprehensive error logging for better debugging
- Ensured all allocated ByteBuf components are released properly

Fixes AutoMQ#2938
Adds comprehensive test coverage for the memory leak fix to ensure:
- ByteBuf resources are properly cleaned up during exceptions
- No memory leaks occur when uploadBulk0() encounters failures
- Exception handling preserves the original error while cleaning up resources
- Direct memory tracking validates proper cleanup

Related to AutoMQ#2938
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Critical Memory Leak in DefaultWriter.uploadBulk0()

2 participants