This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: heap fragmentation & operator new
- From: Andrew Haley <aph at redhat dot com>
- To: Burlen Loring <burlen dot loring at kitware dot com>
- Cc: GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 23 Jun 2008 10:47:36 +0100
- Subject: Re: heap fragmentation & operator new
- References: <485E8748.7090903@kitware.com>
Burlen Loring wrote:
> We have some complaints from our users that if we do not use
> malloc/realloc/free inside our container class, and rather we use
> operator new/delete, that we have heap fragmentation problem that leads
> to their running out of memory. We have evidence that its true
I would like to see such evidence. I don't even believe that this
is possible, given that libstdc++-v3 uses malloc for its new. Here
it is:
_GLIBCXX_WEAK_DEFINITION void *
operator new (std::size_t sz, const std::nothrow_t&) throw()
{
void *p;
/* malloc (0) is unpredictable; avoid it. */
if (sz == 0)
sz = 1;
p = (void *) malloc (sz);
while (p == 0)
{
new_handler handler = __new_handler;
if (! handler)
return 0;
try
{
handler ();
}
catch (bad_alloc &)
{
return 0;
}
p = (void *) malloc (sz);
}
return p;
}
> and additionally we see that additionally realloc gives performance
> advantage.
It gives performance advantage over what, exactly?
Andrew.