Skip to content

Commit

Permalink
objectionary#2251 remove unused cleanUp methods and add todo
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Jun 26, 2024
1 parent 4e7665e commit b1e7212
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
15 changes: 5 additions & 10 deletions eo-runtime/src/main/java/org/eolang/Dataized.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public final class Dataized {

/**
* Max dataization level.
*
* @todo #2251:90min It is necessary to call {@link ThreadLocal#remove()} on "ThreadLocal"
* variables to prevent memory leaks. We should either find a place where this variable can be
* removed, or, if this is not possible (see https://github.com/objectionary/eo/pull/1930),
* come up with another solution.
*/
private static final ThreadLocal<Integer> MAX_LEVEL =
ThreadLocal.withInitial(() -> Integer.getInteger("max.dataization.log", 3));
Expand Down Expand Up @@ -150,14 +155,4 @@ public <T> T take(final Class<T> type) {
}
return type.cast(strong);
}

/**
* Clean up resources.
* This includes call of {@link ThreadLocal#remove()} method to prevent
* memory leaks.
*/
public static void cleanUp() {
Dataized.LEVEL.remove();
Dataized.MAX_LEVEL.remove();
}
}
14 changes: 5 additions & 9 deletions eo-runtime/src/main/java/org/eolang/PhDefault.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public class PhDefault implements Phi, Cloneable {

/**
* Attributes nesting level.
*
* @todo #2251:90min It is necessary to call {@link ThreadLocal#remove()} on "ThreadLocal"
* variables to prevent memory leaks. We should either find a place where this variable can be
* removed, or, if this is not possible (see https://github.com/objectionary/eo/pull/1930),
* come up with another solution.
*/
private static final ThreadLocal<Integer> NESTING = ThreadLocal.withInitial(() -> 0);

Expand Down Expand Up @@ -300,15 +305,6 @@ public String forma() {
return this.form;
}

/**
* Clean up resources.
* This includes call of {@link ThreadLocal#remove()} method to prevent
* memory leaks.
*/
public static void cleanUp() {
PhDefault.NESTING.remove();
}

/**
* Add new attribute.
*
Expand Down
14 changes: 5 additions & 9 deletions eo-runtime/src/main/java/org/eolang/PhTraced.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public final class PhTraced implements Phi {
/**
* Cages that are currently being dataized. If one cage is being datazed, and
* it needs to be dataized inside current dataization, the locator of current object be here.
*
* @todo #2251:90min It is necessary to call {@link ThreadLocal#remove()} on "ThreadLocal"
* variables to prevent memory leaks. We should either find a place where this variable can be
* removed, or, if this is not possible (see https://github.com/objectionary/eo/pull/1930),
* come up with another solution.
*/
private static final ThreadLocal<Map<Integer, Integer>> DATAIZING_CAGES = ThreadLocal
.withInitial(HashMap::new);
Expand Down Expand Up @@ -153,15 +158,6 @@ public byte[] delta() {
return new TracingWhileGetting<>(this.object::delta).get();
}

/**
* Clean up resources.
* This includes call of {@link ThreadLocal#remove()} method to prevent
* memory leaks.
*/
public static void cleanUp() {
PhTraced.DATAIZING_CAGES.remove();
}

/**
* Supplier that traces the cage while gets.
* NOT thread-safe.
Expand Down

0 comments on commit b1e7212

Please sign in to comment.