Solved

singleton and memory leak

Posted on 2002-04-16
7
492 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
ID: 6944531
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
ID: 6945365
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
ID: 6949961
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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
LVL 3

Expert Comment

by:danny_pav
ID: 6951332
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
ID: 6951945
Did you try changing the timeout value as I suggested?
Is it an Exe or Dll housing?
0
 

Author Comment

by:NathalieB
ID: 6957517
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
ID: 7012782
NathalieB provided her own solution. I will refund the points and move the question to PAQ.
 
** Mindphaser - Community Support Moderator **
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 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