Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit eab6382

Browse files
authored
Remove finalize from RecordEventsSpanImpl (#2043)
Fixes #2045 This will reduce GC pressure since the VM will not call Finalizer.register() when creating Span objects. Since this method is synchronized on a static lock it can be a source of contention. It also avoids contention on the same lock when running runFinalizer() as part of GC
1 parent 655ca67 commit eab6382

File tree

2 files changed

+0
-12
lines changed

2 files changed

+0
-12
lines changed

buildscripts/checkstyle.xml

-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@
173173
<message key="name.invalidPattern"
174174
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
175175
</module>
176-
<module name="NoFinalizer"/>
177176
<module name="GenericWhitespace">
178177
<message key="ws.followed"
179178
value="GenericWhitespace ''{0}'' is followed by whitespace."/>

impl_core/src/main/java/io/opencensus/implcore/trace/RecordEventsSpanImpl.java

-11
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,4 @@ private RecordEventsSpanImpl(
586586
timestampConverter != null ? timestampConverter : TimestampConverter.now(clock);
587587
startNanoTime = clock.nowNanos();
588588
}
589-
590-
@SuppressWarnings("NoFinalizer")
591-
@Override
592-
protected void finalize() throws Throwable {
593-
synchronized (this) {
594-
if (!hasBeenEnded) {
595-
logger.log(Level.SEVERE, "Span " + name + " is GC'ed without being ended.");
596-
}
597-
}
598-
super.finalize();
599-
}
600589
}

0 commit comments

Comments
 (0)