Memory leak fix & added test.

This commit is contained in:
Adel El-Beik 2024-10-24 11:20:30 +01:00
parent 60c5e97d54
commit 5544d36875
3 changed files with 42 additions and 1 deletions

View File

@ -110,7 +110,7 @@ buildscript {
ext.jsr305_version = constants.getProperty("jsr305Version") ext.jsr305_version = constants.getProperty("jsr305Version")
ext.shiro_version = '1.10.0' ext.shiro_version = '1.10.0'
ext.artifactory_plugin_version = constants.getProperty('artifactoryPluginVersion') ext.artifactory_plugin_version = constants.getProperty('artifactoryPluginVersion')
ext.hikari_version = '3.3.1' ext.hikari_version = '4.0.3'
ext.liquibase_version = '3.6.3' ext.liquibase_version = '3.6.3'
ext.artifactory_contextUrl = 'https://software.r3.com/artifactory' ext.artifactory_contextUrl = 'https://software.r3.com/artifactory'
ext.publicArtifactURL = 'https://download.corda.net/maven' ext.publicArtifactURL = 'https://download.corda.net/maven'

View File

@ -0,0 +1,39 @@
package net.corda.node.migration
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.node.MockNetwork
import net.corda.testing.node.MockNetworkParameters
import net.corda.testing.node.internal.cordappsForPackages
import org.apache.commons.lang3.SystemUtils
import org.hibernate.internal.SessionFactoryRegistry
import org.junit.Assume
import org.junit.Test
import kotlin.test.assertFalse
class MemoryLeakTest {
@Test(timeout=300_000)
fun `memory leak test`() {
assertFalse(SessionFactoryRegistry.INSTANCE.hasRegistrations())
repeat(1) {
// Start mock network
Assume.assumeTrue(!SystemUtils.IS_JAVA_11)
val mockNetwork = MockNetwork(
MockNetworkParameters(
cordappsForAllNodes = cordappsForPackages(
listOf(
"net.corda.node.services.vault"
)
)
)
).also { mockNetwork ->
mockNetwork.createPartyNode(ALICE_NAME)
}
// Stop mock network
mockNetwork?.stopNodes()
// mockNetwork = null
}
assertFalse(SessionFactoryRegistry.INSTANCE.hasRegistrations())
}
}

View File

@ -73,6 +73,7 @@ import net.corda.testing.node.MockServices.Companion.makeTestDataSourcePropertie
import net.corda.testing.node.TestClock import net.corda.testing.node.TestClock
import org.apache.activemq.artemis.utils.ReusableLatch import org.apache.activemq.artemis.utils.ReusableLatch
import org.apache.sshd.common.util.security.SecurityUtils import org.apache.sshd.common.util.security.SecurityUtils
import org.hibernate.internal.SessionFactoryRegistry
import rx.Observable import rx.Observable
import rx.Scheduler import rx.Scheduler
import rx.internal.schedulers.CachedThreadScheduler import rx.internal.schedulers.CachedThreadScheduler
@ -621,6 +622,7 @@ open class InternalMockNetwork(cordappPackages: List<String> = emptyList(),
} }
messagingNetwork.stop() messagingNetwork.stop()
} }
SessionFactoryRegistry.INSTANCE.clearRegistrations()
} }
/** Block until all scheduled activity, active flows and network activity has ceased. */ /** Block until all scheduled activity, active flows and network activity has ceased. */