Skip to content

Memory not freed on context restart in JpaMetamodel#CACHE with spring.main.lazy-initialization=true #3957

@joaemel

Description

@joaemel

When spring.main.lazy-initialization is true, the LazyInitializationBeanFactoryPostProcessor makes the JpaMetamodelCacheCleanup bean lazy, causing the cleanup to never happen. This manifests in OOMs when running lots of tests with DirtiesContext.

Adding this bean to the context:

    @Bean
    public static LazyInitializationExcludeFilter integrationLazyInitializationExcludeFilter() {
        return (beanName, beanDefinition, beanType)
            -> beanName.equals("org.springframework.data.jpa.util.JpaMetamodelCacheCleanup");
    }

Works around the issue.

This issue was observed in version 3.2.11.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions