PosixSharedMemory::~PosixSharedMemory()
{
	AutoLocker locker;
	OP_CHECK_STATUS(locker.Lock(GetIdentifier()));
	// Decrement ref counter and conditional cleanup.
	RefCounter* rc = GetRefCounter();
	OP_ASSERT(rc);
	if(rc->DecrementAndCheck())
	{
		// We're the last owner of this shared memory.
		// Clean up if there's a callback for that registered:
		if(m_callback.get()) m_callback->Cleanup(Ptr());
		 // Remove the block:
		OP_CHECK_STATUS(m_mem_block->Destroy());
		OP_CHECK_STATUS(locker.Unlink());
	}
}