MicroQuill

Changes in the SmartHeap API

Pool Manipulation

Smartheap 4 transparently and dynamically creates multiple pools (one for each thread) so that multiple threads can be active in their respective heaps simultaneously. The SmartHeap pool manipulation APIs (MemPoolSetSmallBlockSize, MemPoolSetBlockSizeFS, MemPoolSetFloor, MemPoolSetCeiling, MemPoolSetPageSize) can be used with SmartHeap 4 thread-specific pools. All you need to do is reference MemDefaultPool to obtain the current thread's pool. In order to change a setting (such as page size) for all the thread-specific pools, it is necessary to make the API call (e.g. MemPoolSetPageSize(MemDefaultPool, 0x10000) from each thread.
Note: MemDefaultPool is no longer global -- it is now a per-thread value in multi-threaded SmartHeap builds.
This scheme is disabled for apps that use the SmartHeap API to allocate (MemAllocPtr, etc, or new implemented in terms of MemAllocPtr), so existing code will not be broken and developers still have the option of creating custom memory pools. SmartHeap 4's pool/thread enhancement applies only to malloc/new.

Using MemRegisterTask

It is not necessary to call MemRegisterTask or define MemPoolDefaultFlags in SmartHeap 4.0 as in previous SmartHeap versions and on some other platforms. However, if you create your own SmartHeap memory pools, you must still specify MEM_POOL_SERIALIZE in the flags parameter if the pool is referenced in more than one thread. Alternatively you can link your app with a multi-threaded version of the SmartHeap library and the MEM_POOL_SERIALIZE flag will be set automatically.


Knowledge Base
MicroQuill home
HeapAgent | SmartHeap | SwapTuner
HeapAgent free trial | SwapTuner free trial
Prices/ordering