activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: Possible memory leak with ActiveMQ-CPP
Date Wed, 25 Nov 2015 16:39:53 GMT
On 11/25/2015 11:29 AM, spamtrap wrote:
> On Wed, 25 Nov 2015 11:07:53 -0500, Timothy Bish
> <tabish121@gmail.com> wrote:
>
>> On 11/25/2015 10:50 AM, spamtrap wrote:
>>> On Wed, 25 Nov 2015 09:33:38 -0500, Timothy Bish
>>> <tabish121@gmail.com> wrote:
>>>
>>>> On 11/25/2015 05:47 AM, spam trap wrote:
>>>>> Hi,
>>>>>
>>>>> I have the following code:
>>>>>
>>>>> cms::Message *pMessage;
>>>>> ...
>>>>> std::vector<std::string> propertyNames = pMessage->getPropertyNames();
>>>>>
>>>>> According to valgrind this leaks memory.  propertyNames is on the
>>>>> stack BTW.
>>>>>
>>>>> ==27758== 50,039,920 (289,968 direct, 49,749,952 indirect) bytes in
>>>>> 6,041 blocks are definitely lost in loss record 383 of 384
>>>>> ==27758==    at 0x4A075FC: operator new(unsigned long)
>>>>> (vg_replace_malloc.c:298)
>>>>> ==27758==    by 0x5F77EF9: decaf::util::StlMap<std::string,
>>>>> activemq::util::PrimitiveValueNode,
>>>>> decaf::util::comparators::Less<std::string> >::keySet() const
>>>>> (StlMap.h:866)
>>>>> ==27758==    by 0x5C3799E:
>>>>> activemq::commands::ActiveMQMessageTemplate<cms::BytesMessage>::getPropertyNames()
>>>>> const (ActiveMQMessageTemplate.h:109)
>>>>>
>>>>> Any ideas?
>>>>>
>>>>>
>>> >From a quick code inspection I don't see any case where a leak can
>>>> occur.  If you can add a test case to the existing set of unit tests for
>>>> the Message objects to reproduce the valgrind complaint I will look again.

>>>>
>>>> Try adding something to src/test/activemq/commands/ActiveMQMessageTest.h/cpp
>>> Where are the binaries placed for the test programs?  I can't seem to
>>> find them.
>>>
>>>
>>>
>> Depends on how you are building them, what is the environment and build
>> process?
> Linux 64 bit.  I've run:
>
> configure ....
> make
> make install
> make check
>
>
>
So on Linux the autotools the build process will place the executables
in the directory that map to the application being created.

So for instance if you want to build the unit tests the executable is in

./src/test/ and is called activemq-test I believe. 

I generally use a build folder to keep the source and intermediate files
separate, to test and check for leaks I use a process something like the
following. 

cd activemq-cpp
mkdir ./build
./autogen.sh
cd build
../configure --enable-shared=no CXXFLAGS="-g -O0"
make check -j 8
./src/test/activemq-test

or for valgrind (add options to check as you like)

valgrind --tool=memcheck --leak-check=yes ./src/test/activemq-test

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.redhat.com 
twitter: @tabish121
blog: http://timbish.blogspot.com/



Mime
View raw message