I ran valgrind on my application and several issues popped up involving Beanstalk::Client::reconnect(). I will put the report in a separate post in this issue.
I'm not entirely sure how to fix this, but I did notice the following when looking at the code.
When looking at the code, I notice that strings are passed by value. eg:
Client::Client(string host, int port, float secs) {
...
void Client::connect(string _host, int _port, float secs) {
In addition, in reconnect(), connect is called with the member values of host, port and float secs already stored in the instance, which values are then again used to set the exact members passed.
void Client::connect(string _host, int _port, float secs) {
...
host = _host;
port = _port;
timeout_secs = secs;
...
}
...
void Client::reconnect() {
disconnect();
connect(host, port, timeout_secs);
}
This looks like a roundabout way of reconnecting and might be improved by using const string referemces. Since these methods are exactly where the memory issues occur as reported by valgrind, cleaning up might go some way to solve them.
I ran valgrind on my application and several issues popped up involving Beanstalk::Client::reconnect(). I will put the report in a separate post in this issue.
I'm not entirely sure how to fix this, but I did notice the following when looking at the code.
When looking at the code, I notice that strings are passed by value. eg:
In addition, in reconnect(), connect is called with the member values of host, port and float secs already stored in the instance, which values are then again used to set the exact members passed.
This looks like a roundabout way of reconnecting and might be improved by using const string referemces. Since these methods are exactly where the memory issues occur as reported by valgrind, cleaning up might go some way to solve them.