当前位置: 首页>>代码示例>>Java>>正文


Java MemorySegment.getOwner方法代码示例

本文整理汇总了Java中org.apache.flink.core.memory.MemorySegment.getOwner方法的典型用法代码示例。如果您正苦于以下问题:Java MemorySegment.getOwner方法的具体用法?Java MemorySegment.getOwner怎么用?Java MemorySegment.getOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.core.memory.MemorySegment的用法示例。


在下文中一共展示了MemorySegment.getOwner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: release

import org.apache.flink.core.memory.MemorySegment; //导入方法依赖的package包/类
/**
 * Tries to release the memory for the specified segment. If the segment has already been released or
 * is null, the request is simply ignored.
 *
 * <p>If the memory manager manages pre-allocated memory, the memory segment goes back to the memory pool.
 * Otherwise, the segment is only freed and made eligible for reclamation by the GC.
 *
 * @param segment The segment to be released.
 * @throws IllegalArgumentException Thrown, if the given segment is of an incompatible type.
 */
public void release(MemorySegment segment) {
	// check if segment is null or has already been freed
	if (segment == null || segment.getOwner() == null) {
		return;
	}

	final Object owner = segment.getOwner();

	// -------------------- BEGIN CRITICAL SECTION -------------------
	synchronized (lock) {
		// prevent double return to this memory manager
		if (segment.isFreed()) {
			return;
		}
		if (isShutDown) {
			throw new IllegalStateException("Memory manager has been shut down.");
		}

		// remove the reference in the map for the owner
		try {
			Set<MemorySegment> segsForOwner = this.allocatedSegments.get(owner);

			if (segsForOwner != null) {
				segsForOwner.remove(segment);
				if (segsForOwner.isEmpty()) {
					this.allocatedSegments.remove(owner);
				}
			}

			if (isPreAllocated) {
				// release the memory in any case
				memoryPool.returnSegmentToPool(segment);
			}
			else {
				segment.free();
				numNonAllocatedPages++;
			}
		}
		catch (Throwable t) {
			throw new RuntimeException("Error removing book-keeping reference to allocated memory segment.", t);
		}
	}
	// -------------------- END CRITICAL SECTION -------------------
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:55,代码来源:MemoryManager.java


注:本文中的org.apache.flink.core.memory.MemorySegment.getOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。