producer.produce() allows the caller to provide arbitrary data to be included in delivery reports via the opaque parameter. Normally the opaque data is persisted by the call to produce() and then released when the delivery report is made. In the case of an error in produce(), no delivery report ever comes for the message, so the opaque data is never released, resulting in a memory leak.
Assuming a kafka instance running at localhost:9093 (I used the bitnami docker image in my test), and that kafka is setup not to auto-create unknown topics, this script makes it possible to see the leak.
Environment Information
Steps to Reproduce
producer.produce()
allows the caller to provide arbitrary data to be included in delivery reports via theopaque
parameter. Normally the opaque data is persisted by the call toproduce()
and then released when the delivery report is made. In the case of an error inproduce()
, no delivery report ever comes for the message, so the opaque data is never released, resulting in a memory leak.Assuming a kafka instance running at localhost:9093 (I used the bitnami docker image in my test), and that kafka is setup not to auto-create unknown topics, this script makes it possible to see the leak.