TPIE

v1.1rc1-6-g0c97303
Memory manager

TPIE provides various external memory algorithms and data structures, most prominently an external memory priority queue (tpie::ami::priority_queue) and external memory sorting (tpie::sort).

Although these algorithms work correctly with as little as a few megabytes of internal memory available, they will generally perform better the more internal memory they are assigned.

To use the external memory algorithms, you must initialize the memory subsystem using tpie::tpie_init. In order to specify the amount of internal memory to use, set the memory manager's limit as follows:

tpie::get_memory_manager().set_limit(megabytes*1024*1024);

See also tpie::memory_manager.

When you use TPIE to implement your own external memory algorithms, you should use tpie::tpie_new, tpie::tpie_new_array, tpie::tpie_delete and tpie::tpie_delete_array instead of new and delete whenever you allocate and deallocate large amounts of memory. This way, you can design your algorithms to work with the memory manager in TPIE, and built-in TPIE algorithms will respect the amount of memory your implementation has already allocated.

TPIE provides an implementation of the auto pointer paradigm. See tpie::auto_ptr.

int* my_ints = tpie::tpie_new_array<int>(1024);
std::fill(my_ints+0, my_ints+1024, 0);
tpie::tpie_delete_array(my_ints, 1024);
mystack->push(42);
// when mystack goes out of scope, the stack object is deleted with tpie_delete.

You can use the memory_manager methods tpie::memory_manager::used(), tpie::memory_manager::available() and tpie::memory_manager::limit() to inspect the internal memory environment.