-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memory pilling up in publish #30
Comments
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. |
i review my code ,you are right, while consuming msg,i make a rpc request in one channel,so the memory is pilling up. |
when setting "mandatory" bit true,and publishing msg that not routed,program will catch and print exception and memory is piliing up.i think it may be a bug when exception caught.
The text was updated successfully, but these errors were encountered: