Solved

singleton and memory leak

Posted on 2002-04-16
7
490 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

863 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

20 Experts available now in Live!

Get 1:1 Help Now