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 » Developing U++ » U++ TheIDE and Library: Releases and ChangeLogs » Improved heap diagnostics
Improved heap diagnostics [message #14822] Sun, 16 March 2008 15:47 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Debug mode heap diagnostics improved. Write before/past block checks are now more accurate.

Memory leaks now list a "memory breakpoint" value. Add this value to commandline (e.g. "--memory-breakpoint__ 107749") and the U++ will stop at corresponding "new" statement with segmentation fault (something you can catch with debugger and see the call stack). (Of course, if you are about to detect the real culprit, the code must do exactly the same thing..)

Also:

void MemoryIgnoreLeaksBegin();
void MemoryIgnoreLeaksEnd();

supress any memory allocated in between to be considered a memory leak. This can be nested and is thread specific.

Mirek
Re: Improved heap diagnostics [message #14823 is a reply to message #14822] Sun, 16 March 2008 17:51 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Hi Mirek,

FreeBSD does not have flag MAP_ANONYMOUS, but MAP_ANON, so we have to distinguish it from PLATFORM_POSIX.

Matthias
Re: Improved heap diagnostics [message #14824 is a reply to message #14823] Sun, 16 March 2008 19:14 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Like this:

void *SysAllocRaw(size_t size)
{
	LTIMING("SysAllocRaw");
	if(sPeak) *sPeak = MemoryProfile();
	sKB += int(((size + 4095) & ~4095) >> 10);
#ifdef PLATFORM_WIN32
	void *ptr = VirtualAlloc(NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
#else
#ifdef PLATFORM_LINUX
	void *ptr =  mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
#else
	void *ptr =  mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
#endif
#endif
	if(!ptr)
		Panic("Out of memory!");
	return ptr;
}


?

Mirek
Re: Improved heap diagnostics [message #14825 is a reply to message #14824] Sun, 16 March 2008 19:20 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Seems reasonable if other POSIX platforms also have MAP_ANON instead of MAP_ANONYMOUS. But I don't know Sad.

By the way, there are also some #ifdef _DEBUG missing in sources where new functions are used.

Matthias
Re: Improved heap diagnostics [message #14826 is a reply to message #14825] Sun, 16 March 2008 20:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
masu wrote on Sun, 16 March 2008 14:20

Seems reasonable if other POSIX platforms also have MAP_ANON instead of MAP_ANONYMOUS. But I don't know Sad.



I guess, when we get there, we will see Smile In fact, the only other platform to support is Solaris (on Mac, it is MAP_ANON AFAIK).

Quote:


By the way, there are also some #ifdef _DEBUG missing in sources where new functions are used.

Matthias


Well, rather missing "inline"...

Mirek
Re: Improved heap diagnostics [message #14918 is a reply to message #14826] Wed, 19 March 2008 22:19 Go to previous message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
luzr wrote on Sun, 16 March 2008 20:53

Well, rather missing "inline"...


... and missing header guard for Defs.h.

Matthias
Previous Topic: KDE early fix
Next Topic: plugin/zip
Goto Forum:
  


Current Time: Thu Mar 28 22:15:05 CET 2024

Total time taken to generate the page: 0.01917 seconds