--- a/ucx/ucx/mempool.h Mon Feb 04 14:11:57 2019 +0100 +++ b/ucx/ucx/mempool.h Mon Feb 04 17:17:48 2019 +0100 @@ -164,6 +164,9 @@ * * The destructor is automatically called when the memory is freed or the * pool is destroyed. + * A destructor for pooled memory <b>MUST NOT</b> free the memory itself, + * as this is done by the pool. Use a destructor to free any resources + * managed by the pooled object. * * The only requirement for the specified memory is, that it <b>MUST</b> be * pooled memory by a UcxMempool or an element-compatible mempool. The pointer @@ -179,12 +182,18 @@ /** * Registers a destructor function for the specified (non-pooled) memory. - * + * * This is useful, if you have memory that has not been allocated by a mempool, * but shall be managed by a mempool. * * This function creates an entry in the specified mempool and the memory will * therefore (logically) convert to pooled memory. + * <b>However, this does not cause the memory to be freed automatically!</b>. + * If you want to use this function, make the memory pool free non-pooled + * memory, the specified destructor function must call <code>free()</code> + * by itself. But keep in mind, that you then MUST NOT use this destructor + * function with pooled memory (e.g. in ucx_mempool_set_destr()), as it + * would cause a double-free. * * @param pool the memory pool * @param ptr data the destructor is registered for