You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "Pochatkin (via GitHub)" <gi...@apache.org> on 2023/03/03 12:23:27 UTC
[GitHub] [ignite-3] Pochatkin opened a new pull request, #1749: IGNITE-18604 Fix memory leak
Pochatkin opened a new pull request, #1749:
URL: https://github.com/apache/ignite-3/pull/1749
https://issues.apache.org/jira/browse/IGNITE-18604
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] PakhomovAlexander merged pull request #1749: IGNITE-18604 Fix memory leak
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander merged PR #1749:
URL: https://github.com/apache/ignite-3/pull/1749
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] valepakh commented on a diff in pull request #1749: IGNITE-18604 Fix memory leak
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #1749:
URL: https://github.com/apache/ignite-3/pull/1749#discussion_r1124397088
##########
modules/rest-api/src/main/java/org/apache/ignite/internal/rest/RestFactory.java:
##########
@@ -17,8 +17,19 @@
package org.apache.ignite.internal.rest;
+import io.micronaut.runtime.Micronaut;
+
/**
* Factory that produces all beans that is necessary for the controller class.
*/
public interface RestFactory {
+ /**
+ * Destroy method. All resources of factory implementation must be cleaned and all field must be null-pointed.
+ * The reason of these requirements is Micronaut design.
+ * {@link Micronaut#start()} store shutdown hook and capture pointer
+ * to embedded application {@link io.micronaut.http.server.netty.NettyEmbeddedServer} and as result
+ * {@link io.micronaut.context.ApplicationContext} will be not collect by GC never.
+ * All rest factories stored in application context and should be cleaned to prevent memory leak.
Review Comment:
```suggestion
* Destroy method. All resources of the factory implementation must be cleaned and all fields must be set to {@code null}.
* The reason of these requirements is Micronaut design.
* {@link Micronaut#start()} store shutdown hook and capture a pointer
* to the embedded application {@link io.micronaut.http.server.netty.NettyEmbeddedServer} and as a result
* {@link io.micronaut.context.ApplicationContext} will never be collected by the GC.
* All rest factories stored in the application context should be cleaned to prevent memory leak.
```
##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/RestFactoriesDestroyer.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.ignite.internal.rest;
+
+import io.micronaut.context.event.BeanDestroyedEvent;
+import io.micronaut.context.event.BeanDestroyedEventListener;
+import jakarta.inject.Singleton;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+
+/**
+ * Destroyer of any rest factory {@link RestFactory}.
+ */
+@Singleton
+public class RestFactoriesDestroyer implements BeanDestroyedEventListener<RestFactory> {
+ private static final IgniteLogger LOG = Loggers.forClass(RestFactoriesDestroyer.class);
+
+ @Override
+ public void onDestroyed(BeanDestroyedEvent<RestFactory> event) {
+ RestFactory bean = event.getBean();
+ if (bean != null) {
+ LOG.info("Destroy rest factory " + bean);
Review Comment:
Maybe lower the log level to trace?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] PakhomovAlexander commented on a diff in pull request #1749: IGNITE-18604 Fix memory leak
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on code in PR #1749:
URL: https://github.com/apache/ignite-3/pull/1749#discussion_r1124419309
##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/RestFactoriesDestroyer.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.ignite.internal.rest;
+
+import io.micronaut.context.event.BeanDestroyedEvent;
+import io.micronaut.context.event.BeanDestroyedEventListener;
+import jakarta.inject.Singleton;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+
+/**
+ * Destroyer of any rest factory {@link RestFactory}.
+ */
+@Singleton
+public class RestFactoriesDestroyer implements BeanDestroyedEventListener<RestFactory> {
+ private static final IgniteLogger LOG = Loggers.forClass(RestFactoriesDestroyer.class);
+
+ @Override
+ public void onDestroyed(BeanDestroyedEvent<RestFactory> event) {
+ RestFactory bean = event.getBean();
+ if (bean != null) {
+ LOG.info("Destroy rest factory " + bean);
Review Comment:
Debug should be ok
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org