[ 
https://issues.apache.org/jira/browse/KAFKA-4741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15855330#comment-15855330
 ] 

ASF GitHub Bot commented on KAFKA-4741:
---------------------------------------

GitHub user satishd opened a pull request:

    https://github.com/apache/kafka/pull/2509

    KAFKA-4741 Fix for buffer leaks in RecordAccumulator

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/satishd/kafka buffer-cleanup

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/2509.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2509
    
----
commit 8dd4e001fa6e0513a26db76a3b88964afd6784f8
Author: Satish Duggana <sdugg...@hortonworks.com>
Date:   2017-02-06T12:21:23Z

    KAFKA-4741 Fix for buffer leaks in RecordAccumulator

----


> Memory leak in RecordAccumulator.append
> ---------------------------------------
>
>                 Key: KAFKA-4741
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4741
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients
>            Reporter: Satish Duggana
>
> RecordAccumulator creates a `ByteBuffer` from free memory pool. This should 
> be deallocated when invocations encounter an exception or throwing any 
> exceptions. 
> I added todo comment lines in the below code for cases to deallocate that 
> buffer.
> {code:title=RecordProducer.java|borderStyle=solid}
>             ByteBuffer buffer = free.allocate(size, maxTimeToBlock);
>             synchronized (dq) {
>                 // Need to check if producer is closed again after grabbing 
> the dequeue lock.
>                 if (closed)
>                    // todo buffer should be cleared.
>                     throw new IllegalStateException("Cannot send after the 
> producer is closed.");
>                 // todo buffer should be cleared up when tryAppend throws an 
> Exception
>                 RecordAppendResult appendResult = tryAppend(timestamp, key, 
> value, callback, dq);
>                 if (appendResult != null) {
>                     // Somebody else found us a batch, return the one we 
> waited for! Hopefully this doesn't happen often...
>                     free.deallocate(buffer);
>                     return appendResult;
>                 }
> {code}
> I will raise PR for the same soon.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to