How to get the memory block size which allocated by new operator?
- From: "space6" <ispacex@xxxxxxxxx>
- Date: 7 Sep 2006 19:37:43 -0700
In my project,it seemed there is memory leak somewhere.I can't find the
place even by using Numega BoundCheck.then I find a idea.I think I can
use a global variable of integer to save the
memory that not released.When allocate memory by new operator,I will
add the size to the global
variable,and when delete memory,I will sub the size.And I always output
the global viarable by OutputDebugString() API.
I successd at Debug mode.The code to get a buffer's size which
allocated by new operator as following:
int GetNewBufferSize(void *p)
{
if ( p )
#ifdef _Debug
return *(int*)((char *)p-16);
#else
//How to get the memory size in release mode ?
#endif
else
return 0;
}
But it can not work well in the release mode.How can tell me how to get
the memory size in release mode?
Thanks for advanced!
ispacex
2006/09/08
.
- Follow-Ups:
- Re: How to get the memory block size which allocated by new operator?
- From: Alan Carre
- Re: How to get the memory block size which allocated by new operator?
- From: Tom Widmer [VC++ MVP]
- Re: How to get the memory block size which allocated by new operator?
- Prev by Date: Re: CPageSetupDialog
- Next by Date: UNICODE SUPPORT FOR VC++6 EDITOR
- Previous by thread: CPageSetupDialog
- Next by thread: Re: How to get the memory block size which allocated by new operator?
- Index(es):
Relevant Pages
|
Loading