[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

singleton and memory leak

Posted on 2002-04-16
7
Medium Priority
?
510 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
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.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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. …
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 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.
Suggested Courses

873 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