code: @Override
  	public void release(MemorySegment segment) {
  		// check if segment is null or has already been freed
  		if (segment == null || segment.isFreed() || !(segment instanceof DefaultMemorySegment)) {
  			return;
  		}
  		
  		final DefaultMemorySegment defSeg = (DefaultMemorySegment) segment;
  		final AbstractInvokable owner = defSeg.owner;
  		
  		// -------------------- BEGIN CRITICAL SECTION -------------------
  		synchronized (this.lock)
  		{
  			if (this.isShutDown) {
  				throw new IllegalStateException("Memory manager has been shut down.");
  			}
  
  			// remove the reference in the map for the owner
  			try {
  				Set<DefaultMemorySegment> segsForOwner = this.allocatedSegments.get(owner);
  				
  				if (segsForOwner != null) {
  					segsForOwner.remove(defSeg);
  					if (segsForOwner.isEmpty()) {
  						this.allocatedSegments.remove(owner);
  					}
  				}
  			}
  			catch (Throwable t) {
  				LOG.error("Error removing book-keeping reference to allocated memory segment.", t);
  			}
  			finally {
  				// release the memory in any case
  				byte[] buffer = defSeg.destroy();
  				this.freeSegments.add(buffer);
  			}
  		}
  		// -------------------- END CRITICAL SECTION -------------------
  	}
docs: ------------------------------------------------------------------------