tillrohrmann commented on a change in pull request #11109: 
[FLINK-15758][MemManager] Release segment and its unsafe memory in GC Cleaner
URL: https://github.com/apache/flink/pull/11109#discussion_r410265250
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/memory/UnsafeMemoryBudget.java
 ##########
 @@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.memory;
+
+import org.apache.flink.util.JavaGcCleanerWrapper;
+
+import javax.annotation.Nonnegative;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Tracker of memory allocation and release within a custom limit.
+ *
+ * <p>This memory management in Flink uses the same approach as Java uses to 
allocate direct memory
+ * and release it upon GC but memory here can be also released directly with 
{@link #releaseMemory(long)}.
+ * The memory reservation {@link #reserveMemory(long)} tries firstly to run 
all phantom cleaners, created with
+ * {@link 
org.apache.flink.core.memory.MemoryUtils#createMemoryGcCleaner(Object, long, 
Runnable)},
+ * for objects which are ready to be garbage collected. If memory is still not 
available, it triggers GC and
+ * continues to process any ready cleaners making {@link #MAX_SLEEPS} attempts 
before throwing {@link OutOfMemoryError}.
+ */
+class UnsafeMemoryBudget {
+       // max. number of sleeps during try-reserving with exponentially
+       // increasing delay before throwing OutOfMemoryError:
+       // 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 (total 1023 ms ~ 1 s)
+       // which means that OOME will be thrown after 0.5 s of trying
 
 Review comment:
   ```suggestion
        // which means that OOME will be thrown after 1 s of trying
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to