Boost logo

Boost Users :

Subject: [Boost-users] [pool] Memory usage with boost::pool
From: Daniele Barzotti (daniele.barzotti_at_[hidden])
Date: 2011-07-08 05:44:00


Hi,

in my project I try to use boost::pool to handle memory
allocation/deallocation.

I have a MemoryManager object with two simple methods:

void* WaveStreamMM::AllocateBuffer(size_t numbytes, int memtype)
{
  boost::mutex::scoped_lock lock(m_mutex);
  void *buf = m_pool.ordered_malloc(numbytes);
  memset(buf, 0, numbytes);

  return buf;
}

void WaveStreamMM::FreeBuffer(void *p)
{
  boost::mutex::scoped_lock lock(m_mutex);
  m_pool.free(p);
}

If I use the code above, the memory usage of my application increase
over the time, while if I substitute the allocation/deallocation
respectively with:

void *buf = malloc(numbytes);

and

free(p);

the memory usage remains constant.
I wrong something?

Regards,
Daniele.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net