Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Heap Leaks Detected
Heap Leaks Detected [message #20861] Wed, 15 April 2009 01:27 Go to next message
MohamedMonem is currently offline  MohamedMonem
Messages: 7
Registered: March 2009
Promising Member
Hi All

can any one tell me whats make the application pop up this error (Heap Leaks Detected) after closing it !!

thanx in advance Smile

[Updated on: Wed, 15 April 2009 01:28]

Report message to a moderator

Re: Heap Leaks Detected [message #20862 is a reply to message #20861] Wed, 15 April 2009 09:09 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
U++ keeps track of dynamic allocation and warns you if you have a memory leak. It means that you have not deleted something that you have newed. The warning will show up as long as you do not correct the memory leak. AFAIK there are some built-in means to help you detect where the leak is, but I have never used them.

By using U++ containers you can avoid having to delete you allocated data in more that 95% of cases (and in almost all of the above cases the call to new also), but U++ lacks an auto_ptr type for the rare cases when you do need to new a single item and delete it at some point.
Re: Heap Leaks Detected [message #20863 is a reply to message #20862] Wed, 15 April 2009 09:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
There is a bit of info:

http://www.ultimatepp.org/srcdoc$Core$Leaks$en-us.html

Mirek
Re: Heap Leaks Detected [message #20864 is a reply to message #20862] Wed, 15 April 2009 10:00 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
cbpporter wrote on Wed, 15 April 2009 08:09

U++ keeps track of dynamic allocation and warns you if you have a memory leak. It means that you have not deleted something that you have newed. The warning will show up as long as you do not correct the memory leak. AFAIK there are some built-in means to help you detect where the leak is, but I have never used them.

By using U++ containers you can avoid having to delete you allocated data in more that 95% of cases (and in almost all of the above cases the call to new also), but U++ lacks an auto_ptr type for the rare cases when you do need to new a single item and delete it at some point.


Doesn't the One<> template provide this functionality?
Re: Heap Leaks Detected [message #20865 is a reply to message #20864] Wed, 15 April 2009 10:19 Go to previous messageGo to next message
TeCNoYoTTa is currently offline  TeCNoYoTTa
Messages: 138
Registered: July 2008
Location: Egypt
Experienced Member

thanks all ....but i think that the problem in our program is that there is a thread that don't close !! how can we fix this

we made a thread that contains
while(true)
how can we change it to while the program is opened ?

thx in advance
Re: Heap Leaks Detected [message #20866 is a reply to message #20864] Wed, 15 April 2009 11:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mrjt wrote on Wed, 15 April 2009 04:00

cbpporter wrote on Wed, 15 April 2009 08:09

U++ keeps track of dynamic allocation and warns you if you have a memory leak. It means that you have not deleted something that you have newed. The warning will show up as long as you do not correct the memory leak. AFAIK there are some built-in means to help you detect where the leak is, but I have never used them.

By using U++ containers you can avoid having to delete you allocated data in more that 95% of cases (and in almost all of the above cases the call to new also), but U++ lacks an auto_ptr type for the rare cases when you do need to new a single item and delete it at some point.


Doesn't the One<> template provide this functionality?


Definitely.

Although, according to U++ way of thinking (and as it progresses), One is considered to be a containter. And instead of 'new', I believe it is better to use 'Create' for in-place creation.

Mirek
Re: Heap Leaks Detected [message #20868 is a reply to message #20866] Wed, 15 April 2009 13:07 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
mrjt wrote on Wed, 15 April 2009 11:00


Doesn't the One<> template provide this functionality?

I stand corrected. Forgot about One. Just proves how rarely in need to keep track of resources through pointers Smile.
luzr wrote on Wed, 15 April 2009 12:40


Definitely.

Although, according to U++ way of thinking (and as it progresses), One is considered to be a containter. And instead of 'new', I believe it is better to use 'Create' for in-place creation.


In place creation is really nice in general. Too bad C++ doesn't offer an in place creation mechanism, something like a delayed constructor.
Re: Heap Leaks Detected [message #20873 is a reply to message #20868] Wed, 15 April 2009 16:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 15 April 2009 07:07

mrjt wrote on Wed, 15 April 2009 11:00


Doesn't the One<> template provide this functionality?

I stand corrected. Forgot about One. Just proves how rarely in need to keep track of resources through pointers Smile.
luzr wrote on Wed, 15 April 2009 12:40


Definitely.

Although, according to U++ way of thinking (and as it progresses), One is considered to be a containter. And instead of 'new', I believe it is better to use 'Create' for in-place creation.


In place creation is really nice in general. Too bad C++ doesn't offer an in place creation mechanism, something like a delayed constructor.



As a matter of fact, I believe it does, the only problem is that for containers, the only constructor possible is default (paremeter-less) one.

But I guess that is only a samall price to pay. I generally consider parametric constructors either special case tools (e.g. Mutex::Lock) or suplementary (FileIn).

Mirek
Re: Heap Leaks Detected [message #21820 is a reply to message #20865] Sun, 07 June 2009 00:49 Go to previous message
sapiency is currently offline  sapiency
Messages: 56
Registered: September 2008
Member
TeCNoYoTTa wrote on Wed, 15 April 2009 10:19

thanks all ....but i think that the problem in our program is that there is a thread that don't close !! how can we fix this

we made a thread that contains
while(true)
how can we change it to while the program is opened ?

thx in advance


just put
	
while (0 < Thread().GetCount())
{
  RLOG("[" << GetSysTime() << "." <<  "] " 
    << __func__ << " Sleep(1) due of " << Thread().GetCount()
    << " Running threads"
    );	
  Sleep(1);
}

in the destructor (for me it was the destructor of the class where the threads were created)
This will prevent to close the gui before the threads are closed.

regards

reinhard
Previous Topic: Small fix for valgrind
Next Topic: Why struct instead of class?
Goto Forum:
  


Current Time: Fri Mar 29 06:24:53 CET 2024

Total time taken to generate the page: 0.03341 seconds