?
Solved

singleton and memory leak

Posted on 2002-04-16
7
Medium Priority
?
505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

800 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