of

Wraps memoryService and takes ownership of it: close also closes it if it is AutoCloseable.