Discussion:
ActiveMQ-CPP 3.4.2 memory leaks?
richardm
2012-05-13 11:42:30 UTC
Permalink
I've noticed the activemq-cpp-example program leaks quite a bit. Has any one
else noticed this?

I'm using Visual Studio 2008.

--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-3-4-2-memory-leaks-tp4630355.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Timothy Bish
2012-05-13 13:25:16 UTC
Permalink
Post by richardm
I've noticed the activemq-cpp-example program leaks quite a bit. Has any one
else noticed this?
I'm using Visual Studio 2008.
--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-3-4-2-memory-leaks-tp4630355.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
There aren't any known leaks. If you can run the code through a memory
profiler on Windows and see where the leaks you are seeing are coming
from we can work to address them. Without something more conclusive
there there's not much we can do.
--
Tim Bish
Sr Software Engineer | FuseSource Corp
tim.bish-***@public.gmane.org | www.fusesource.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/
richardm
2012-05-13 14:32:12 UTC
Permalink
Thanks Tim,

I'm new to the group. Does this mean that most of the development is done
on Linux? This might be a Windows (Microsoft) -specific issue.

My tools are not that good, though I'll spend some time later today or
tomorrow to better understanding what I'm seeing. All I know is that the
most basic dump of leaked memory indicates quite a few problems in the
Visual Studio environment. I'm guessing this to be the same issue that I'm
bumping up against in my program.

If there's anyone else who has useful Windows tools, any effort would be
most helpful. I've described my changes to the program below.


Richard


---------------------------------

What I have done is put the following the declarative section of the program
(line 41, after #includes):

#ifdef _DEBUG
#ifndef DEBUG_NEW
#include <stdlib.h>
#include <crtdbg.h>

#define _CRTDBG_MAP_ALLOC
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
#endif

And then the following at the bottom of main():

#ifdef _DEBUG
_CrtDumpMemoryLeaks();
#endif

In reality the first change needs to be installed in all the ActiveMQ-cpp
source code, but I haven't reached that point yet. This is a simplistic
approach to instruct the memory allocator to track memory usage and then to
dump the display leakage. (google for more details.)



--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-3-4-2-memory-leaks-tp4630355p4630522.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Timothy Bish
2012-05-13 15:45:08 UTC
Permalink
Post by richardm
Thanks Tim,
I'm new to the group. Does this mean that most of the development is done
on Linux? This might be a Windows (Microsoft) -specific issue.
My tools are not that good, though I'll spend some time later today or
tomorrow to better understanding what I'm seeing. All I know is that the
most basic dump of leaked memory indicates quite a few problems in the
Visual Studio environment. I'm guessing this to be the same issue that I'm
bumping up against in my program.
If there's anyone else who has useful Windows tools, any effort would be
most helpful. I've described my changes to the program below.
Richard
Yes, the code is primarily developed on Linux, and tested with Valgrind
there quite frequently. Its possible there is some leak in the Windows
specific portions or the MS tooling is just giving you false positives.
Not sure if there is anything like Valgrind that is free on Windows.
Post by richardm
---------------------------------
What I have done is put the following the declarative section of the program
#ifdef _DEBUG
#ifndef DEBUG_NEW
#include <stdlib.h>
#include <crtdbg.h>
#define _CRTDBG_MAP_ALLOC
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
#endif
#ifdef _DEBUG
_CrtDumpMemoryLeaks();
#endif
In reality the first change needs to be installed in all the ActiveMQ-cpp
source code, but I haven't reached that point yet. This is a simplistic
approach to instruct the memory allocator to track memory usage and then to
dump the display leakage. (google for more details.)
--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-3-4-2-memory-leaks-tp4630355p4630522.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
--
Tim Bish
Sr Software Engineer | FuseSource Corp
tim.bish-***@public.gmane.org | www.fusesource.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/
Ivan Pechorin
2012-05-13 17:24:50 UTC
Permalink
Post by richardm
My tools are not that good, though I'll spend some time later today or
tomorrow to better understanding what I'm seeing. All I know is that the
most basic dump of leaked memory indicates quite a few problems in the
Visual Studio environment. I'm guessing this to be the same issue that I'm
bumping up against in my program.
If there's anyone else who has useful Windows tools, any effort would be
most helpful. I've described my changes to the program below.
If you could share some program that uses activemq-cpp and seems to leak, I
can compile it with VS2008 (32-bit) and use BoundsChecker tool to check for
leaks and other problems.

I'm interested because we use ActiveMQ-CPP on Windows (VS2008 and VS2010)
in production systems.
richardm
2012-05-13 22:35:44 UTC
Permalink
Check the example program (in the activemq-cpp-example) project that's
provided with the ActiveMQ-cpp source distribution, as I mentioned above.

Thanks.

--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-CPP-3-4-2-memory-leaks-tp4630355p4631106.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Ivan Pechorin
2012-05-18 14:36:11 UTC
Permalink
I'm wondering whether or not you've been able to find out anything using
BoundsChecker or when you might have time to test it? I have access to
another tool which is not as good as what you have; it will probably take
me a couple of days before I have something I'm comfortable sharing .
Let me know if there are any questions.
I've built version 3.4.2, configuration "ReleaseDLL", platform "Win32",
using Visual Studio 2008 with SP1 and all updates/hotfixes up to date
(v9.0.30729.1 SP)
Just two projects: activemq-cpp (the library) and activemq-cpp-example.

I had to change projects' configuration in two places:
1) in both of these projects, in section General -> Character set --
changed from Unicode to "Not set" (first of all, we never use Unicode
builds except for some rare cases where it is really necessary; second,
version 3.4.2 just doesn't compile with Unicode defined: 3 compilation
errors in src\main\decaf\lang\System.cpp)
2) in activemq-cpp-example for configuration "ReleaseDLL" I had to change
Linker -> Input -> Additional dependencies to "activemq-cpp.lib" (the
original list of dependencies was plain wrong) and in Linker -> General ->
Additional Library Directories I had to
put $(SolutionDir)$(PlatformName)\$(ConfigurationName) - that's the
directory where activemq-cpp.lib is stored.

No changes to source code of the example or the library.

I've run activemq-cpp-example against activemq-5.6.0 broker (just fresh
broker downloaded from apache web site, nothing configured at all, just
extracted from zip).

DevPartner Error Detection (that's the current name of the product
previously known as BoundsChecker) didn't find any memory leaks at
all. There was a one-time resource leak: some library was loaded with
LoadLibrary() in apr, and it was not unloaded on application exit. That's
not an issue, in my opinion.

OS: Windows 2008 R2 Standard (64-bit).

Any ideas?
Maybe some other configuration, or some changes to the example?


Regards,
Ivan

Loading...