Giter Site home page Giter Site logo

Comments (2)

alanxz avatar alanxz commented on July 28, 2024

I cannot reproduce the behavior you're describing with the following program:

#include <SimpleAmqpClient/SimpleAmqpClient.h>

#include <iostream>

using namespace AmqpClient;

int main()
{
  Channel::ptr_t channel = AmqpClient::Channel::Create();

  for (int i = 0; i < 1000000; ++i)
  {
    try
    {
      BasicMessage::ptr_t message = AmqpClient::BasicMessage::Create(std::string(1024*128, 'a'));
      channel->BasicPublish("", "noroute", message, true, true);
      return 0;
    }
    catch (MessageReturnedException &e)
    {
      std::cout << "Message delivery error: " << e.what() << std::endl;
    }
  }

  return 0;
}

That said rabbitmq-c, the library that SimpleAmqpClient wraps, has a limitation in the way it handles memory such that memory can only be released if all of the amqp_frame_t objects allocated since the last call to amqp_maybe_release_buffers() are no longer needed.

In your situation its likely SimpleAmqpClient has received other frames, probably from a consumer, from the broker while your code tries repeatedly to send the message, and thus cannot release memory.

There is a known issue that in certain pathological cases where you have two or more active consumers its possible that the library won't release any memory allocated until the AmqpClient::Channel object is destroyed. In the average case I don't this isn't an issue. A fix for this issue requires support from rabbitmq-c for finer grained memory control, which doesn't exist yet.

The workaround for this issue is to use multiple AmqpClient::Channel objects for each different consumer.

from simpleamqpclient.

chenyujian avatar chenyujian commented on July 28, 2024

i review my code ,you are right, while consuming msg,i make a rpc request in one channel,so the memory is pilling up.

from simpleamqpclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.