You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "tabish121 (via GitHub)" <gi...@apache.org> on 2023/04/03 15:20:49 UTC

[GitHub] [activemq-artemis] tabish121 commented on a diff in pull request #4418: ARTEMIS-4206 Adding debug support for large messages not being removed

tabish121 commented on code in PR #4418:
URL: https://github.com/apache/activemq-artemis/pull/4418#discussion_r1156111850


##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ObjectCleaner.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.activemq.artemis.utils;
+
+import java.lang.ref.Cleaner;
+
+public class ObjectCleaner {
+
+   private static final Cleaner cleaner;
+   static {
+      cleaner = Cleaner.create();
+   }
+
+   public static void register(Object obj, Runnable callback) {

Review Comment:
   An issue here with this Cleaner wrapper is that it doesn't really expose a cleaner API that is compatible with the JDK Cleaner appropriate usage.  You are meant to take the returned Cleanable from the Cleaner API and actually call clean on it in most cases leaving the Cleaner to handle those rare or missed cases where a cleanable resource wasn't actively closed and "cleaned" up by the user code.  Just putting every resource into a Cleaner and waiting on it to actually manage the cleanup will likely result in untimely reclaim of resources and bloat in the tracking structures.  



-- 
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.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org