浏览代码

JoinPointImpl: Remove thread-locals after usage, where possible

Avoid potential ThreadLocalMap.Entry accumulation. Entry is a
WeakReference. When JoinPointImpl objects are collected by GC, Entry
instances are still be referenced by ThreadLocalMap, which leads to
memory pressure and potentially more full GCs. So, we proactively remove
ThreadLocal<Integer> arcIndex instances when arcIndex has been
decremented back to -1 per thread. This is not perfect, because not each
thread can be expected to proceed, but it should ameliorate the
situation to some degree.

Fixes #302.

Co-authored-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Signed-off-by: KimmingLau <294001791@qq.com>
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tags/V1_9_22_1
KimmingLau 1 个月前
父节点
当前提交
70a4547610
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5
    1
      runtime/src/main/java/org/aspectj/runtime/reflect/JoinPointImpl.java

+ 5
- 1
runtime/src/main/java/org/aspectj/runtime/reflect/JoinPointImpl.java 查看文件

@@ -154,7 +154,11 @@ class JoinPointImpl implements ProceedingJoinPoint {
arcs = new ArrayList<>();
}
if (arc == null) {
arcIndex.set(arcIndex.get() - 1);
int newIndex = arcIndex.get() - 1;
if (newIndex > -1)
arcIndex.set(newIndex);
else
arcIndex.remove();
}
else {
this.arcs.add(arc);

正在加载...
取消
保存