diff --git a/pax-logging-it/pom.xml b/pax-logging-it/pom.xml
index 6d6cc5fc9..51882bb18 100644
--- a/pax-logging-it/pom.xml
+++ b/pax-logging-it/pom.xml
@@ -69,6 +69,7 @@
1
false
false
+ -Xmx64M -XX:+HeapDumpOnOutOfMemoryError
diff --git a/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/Log4J1MemoryIntegrationTest.java b/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/Log4J1MemoryIntegrationTest.java
new file mode 100644
index 000000000..44e88ae32
--- /dev/null
+++ b/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/Log4J1MemoryIntegrationTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.ops4j.pax.logging.it;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.ops4j.pax.exam.OptionUtils.combine;
+
+@RunWith(PaxExam.class)
+public class Log4J1MemoryIntegrationTest extends AbstractControlledIntegrationTestBase {
+
+ @Configuration
+ public Option[] configure() throws IOException {
+ return combine(
+ combine(baseConfigure(), defaultLoggingConfig()),
+
+ paxLoggingApi(),
+ paxLoggingLog4J1(),
+ configAdmin(),
+ eventAdmin()
+ );
+ }
+
+ @Test
+ public void memoryIssues() throws IOException {
+ LOG.info("Starting");
+ String[] loggerNames = new String[10_000];
+ for (int i = 0; i < 10_000; i++) {
+ loggerNames[i] = UUID.randomUUID().toString();
+ }
+ for (int i = 0; i < 1_000_000; i++) {
+ if (i % 10_000 == 0) {
+ LOG.info("iteration {}", i);
+ System.gc();
+ }
+ new MyClass(loggerNames[i % 10_000]).run();
+ }
+ LOG.info("Done");
+ }
+
+ private static class MyClass {
+ private Logger nonStaticLogger;
+
+ public MyClass(String name) {
+ this.nonStaticLogger = LoggerFactory.getLogger(name);
+ }
+
+ public void run() {
+ // running a method
+ nonStaticLogger.trace("Hello!");
+ }
+ }
+
+}
diff --git a/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/Log4J2MemoryIntegrationTest.java b/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/Log4J2MemoryIntegrationTest.java
new file mode 100644
index 000000000..f302e2ec0
--- /dev/null
+++ b/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/Log4J2MemoryIntegrationTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.ops4j.pax.logging.it;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.ops4j.pax.exam.OptionUtils.combine;
+
+@RunWith(PaxExam.class)
+public class Log4J2MemoryIntegrationTest extends AbstractControlledIntegrationTestBase {
+
+ @Configuration
+ public Option[] configure() throws IOException {
+ return combine(
+ combine(baseConfigure(), defaultLoggingConfig()),
+
+ paxLoggingApi(),
+ paxLoggingLog4J2(),
+ configAdmin(),
+ eventAdmin()
+ );
+ }
+
+ @Test
+ public void memoryIssues() throws IOException {
+ LOG.info("Starting");
+ String[] loggerNames = new String[10_000];
+ for (int i = 0; i < 10_000; i++) {
+ loggerNames[i] = UUID.randomUUID().toString();
+ }
+ for (int i = 0; i < 1_000_000; i++) {
+ if (i % 10_000 == 0) {
+ LOG.info("iteration {}", i);
+ System.gc();
+ }
+ new Log4J2MemoryIntegrationTest.MyClass(loggerNames[i % 10_000]).run();
+ }
+ LOG.info("Done");
+ }
+
+ private static class MyClass {
+ private Logger nonStaticLogger;
+
+ public MyClass(String name) {
+ this.nonStaticLogger = LoggerFactory.getLogger(name);
+ }
+
+ public void run() {
+ // running a method
+ nonStaticLogger.trace("Hello!");
+ }
+ }
+
+}
diff --git a/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/LogbackMemoryIntegrationTest.java b/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/LogbackMemoryIntegrationTest.java
new file mode 100644
index 000000000..eaa67265a
--- /dev/null
+++ b/pax-logging-it/src/test/java/org/ops4j/pax/logging/it/LogbackMemoryIntegrationTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.ops4j.pax.logging.it;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.ops4j.pax.exam.OptionUtils.combine;
+
+@RunWith(PaxExam.class)
+public class LogbackMemoryIntegrationTest extends AbstractControlledIntegrationTestBase {
+
+ @Configuration
+ public Option[] configure() throws IOException {
+ return combine(
+ combine(baseConfigure(), defaultLoggingConfig()),
+
+ paxLoggingApi(),
+ paxLoggingLogback(),
+ configAdmin(),
+ eventAdmin()
+ );
+ }
+
+ @Test
+// @Ignore("Logback in this scenario is broken beyond any repair.")
+ public void memoryIssues() throws IOException {
+ LOG.info("Starting");
+ String[] loggerNames = new String[10_000];
+ for (int i = 0; i < 10_000; i++) {
+ loggerNames[i] = UUID.randomUUID().toString();
+ }
+ for (int i = 0; i < 1_000_000; i++) {
+ if (i % 10_000 == 0) {
+ LOG.info("iteration {}", i);
+ System.gc();
+ }
+ new LogbackMemoryIntegrationTest.MyClass(loggerNames[i % 10_000]).run();
+ }
+ LOG.info("Done");
+ }
+
+ private static class MyClass {
+ private Logger nonStaticLogger;
+
+ public MyClass(String name) {
+ this.nonStaticLogger = LoggerFactory.getLogger(name);
+ }
+
+ public void run() {
+ // running a method
+ nonStaticLogger.trace("Hello!");
+ }
+ }
+
+}