Add mctx attach/detach when creating/destroying a memory pool
This should make sure that the memory context is not destroyed before the memory pool, which is using the context.
Closes #3515 (closed)
This should make sure that the memory context is not destroyed before the memory pool, which is using the context.
Closes #3515 (closed)