Skip to content

[BUG] Azure Service Bus SDK - Possible Memory Leak #47508

@krisztian-toth-all

Description

@krisztian-toth-all

Describe the bug
Running a ServiceBusProcessorClient with #sessionProcessor is potentially leaking when there are no messages produced on the queue.
Same symptoms as #44228.

Exception or Stack Trace
N/A

To Reproduce
Run the following snippet for an extended period of time, observe Heap usage:

ServiceBusProcessorClient processorClient = new ServiceBusClientBuilder()
        .connectionString(URL)
        .sessionProcessor()
        .maxConcurrentSessions(200)
        .maxConcurrentCalls(1)
        .sessionIdleTimeout(Duration.ofMillis(500))
        .queueName(QUEUE_NAME)
        .processMessage(m -> {})
        .processError(e -> e.getException().printStackTrace())
        .buildProcessorClient();

processorClient.start();

try {
    while (true) { }
} catch (Exception e) {
    e.printStackTrace();
} finally {
    processorClient.close();
}

Code Snippet
See above.

Expected behavior
Stable heap usage with objects properly released.

Screenshots
N/A

Setup (please complete the following information):

  • OS: Windows 11/Ubuntu 22.04
  • IDE: IntelliJ
  • Library/Libraries: com.azure:azure-messaging-servicebus:7.17.16
  • Java version: 11
  • App Server/Environment: Tomcat
  • Frameworks: Spring 4.x

Additional context
We noticed this while the consumers are idle, i.e. no messages produced on the queue. However, this prevents us from switching to Service Bus confidently, since we see an increased heap usage when the listeners aren't active with the possibility of a leak. As I mentioned,
Our use-case is a high throughput queue (thousands of messages per minute) with guaranteed FIFO processing. This was already reported back in February by another user, see #44228.

Information Checklist

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.Service Buscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions