Re: heap fragmentation & operator new

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux