Solved

singleton and memory leak

Posted on 2002-04-16
7
489 Views
Last Modified: 2010-05-18
Hello ,

Do you hear about memory leak bent to the use
Of the singleton of Ace(5.2)
Ex:
Class T
{
public:
     …
     friend class ACE_Singleton<T, ACE_Recursive_Thread_Mutex>;

protected:
     …
T ( ) {};
Private:
     …

}
typedef ACE_Singleton<T, ACE_Recursive_Thread_Mutex> TSingleton;

P.S : we’re working multi_thread.

Thanks by advance.
Nathalie.
0
Comment
Question by:NathalieB
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 3

Expert Comment

by:GGRUNDY
Comment Utility
I had a problem once associated with singletons and apparent memory leaks. The problems was due to the fact that once a singleton is created, the housing doesn't destroy it on the last release incase someone else is going to want it. There is quite a long timeout period before it really is disgarded, from memory I got the housing to behave closer to my expectations by changing the following line

const DWORD dwTimeOut = 0; // was 5000; // time for EXE to be idle before shutting down


This may not be your problem - but worth a try.

Cheers
0
 
LVL 3

Expert Comment

by:danny_pav
Comment Utility
I once had a similar problem.  The leak reporting was occurring before the destructors were called.  A leak was reported but it was not a leak.  You can confirm this by putting a breakpoint on the destructor.  If you see leaks reported already when the breakpoint is hit, you had the same "phantom" leaks.
0
 

Author Comment

by:NathalieB
Comment Utility
hello,
It's true.
The leak occures before the calling to the cleanup
function(/* delete this;...*/)!!!!!!!
Do i have to accuse
    my code : sequence of calling functions,
    the boundschecker,
    or the type of singleton that we chose ?
Thanks.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:danny_pav
Comment Utility
So, there is no leak?  Then the fault lies with the reporting.

You can eliminate this from reporting by using CNoTrackObject or other ways to get the reporting of the leak to stop.
0
 
LVL 3

Expert Comment

by:GGRUNDY
Comment Utility
Did you try changing the timeout value as I suggested?
Is it an Exe or Dll housing?
0
 

Author Comment

by:NathalieB
Comment Utility
HELLO,
it's a exe housing.
Sorry,The time has no influence in this phenomena.
I "solve" the problem with an not casher solution:
i call to my cleanup objects,
and to the explicit destructor:
the ACE_Object_Manager::instance()->fini();
Regards.
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
Comment Utility
NathalieB provided her own solution. I will refund the points and move the question to PAQ.
 
** Mindphaser - Community Support Moderator **
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now