Hi:
I try fast_pool_allocator and it does not release memory. See the following
program
Any ideas?
Thanks!
-Kawasaki
--- Begin ---
#include <vector>
#include
#include <list>
using namespace std;
using namespace boost;
#include "memusage.cpp"
//--------------------------------------------------
void func()
{
list v;
// list<int> v;
for (int i = 0; i < 1000000; ++i) {
v.push_back(i);
}
printf("2. MEM USAGE = %d\n", getMemUsage());
}
//--------------------------------------------------
int main(int argc, char **argv)
{
printf("1. MEM USAGE = %d\n", getMemUsage());
func();
func();
func();
/// Exiting the function does NOT free the system memory allocated by the
pool allocator
// You must call
// boost::singleton_pool::release_memory()
// in order to force that
printf("3. MEM USAGE = %d\n", getMemUsage());
boost::singleton_pool::release_memory();
printf("4. MEM USAGE = %d\n", getMemUsage());
return 1;
}
--- END
output
1. MEM USAGE = 11 MB
2. MEM USAGE = 35
2. MEM USAGE = 35
2. MEM USAGE = 35
3. MEM USAGE = 35
4. MEM USAGE = 35 // after release_memory() is called,