zDev - M2E - WTP OSS
  1. zDev - M2E - WTP OSS
  2. MECLIPSEWTP-241

memory leak with "Update project" and packaging war - VirtualComponent$ResourceAdapter instances grow

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Global Rank:
      25343

      Description

      First, I'm not really sure that bug is in m2e-wtp, but I found only this way with m2e-wtp to reproduce it. Please accept my apologies if it is not a m2e-wtp problem.

      Steps to reproduce:
      1) eclipse 3.7.2 (indigo SR2), m2e 1.1m6, latest m2e-wtp
      2) open view Servers and create a server
      3) add a project with packaging war in pom.xml on the server
      4) perform action "Update project" maven menu
      5) repeat 4) many times

      in heap you can see new instance of org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent$ResourceAdapter and those instance survive full GC (see attached screenshot from Memory Analyzer)

      Allocations for new instances is:
      if (projectResource != null && !projectResource.eAdapters().contains(resourceAdapter))
      projectResource.eAdapters().add(resourceAdapter);

      from method:
      org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent.addManagedResource()

      but that condition !projectResource.eAdapters().contains(resourceAdapter) returns every time false and projectResource.eAdapters() grows.

      1. meclipsewtp241.tar.gz
        2 kB
        Martin Kočí
      1. TypeRelations.jpg
        51 kB
      2. PathsToGCRoot.jpg
        199 kB

        Activity

        Hide
        Martin Kočí added a comment -

        Patch from Memory Analyzer. You can see 5 instances of org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent$ResourceAdapter hold with org.eclipse.wst.common.internal.emf.resource.ReferencedXMIResourceImpl$ESynchronizedAdapterList

        Whats important all 5 instances refers same dependency from pom.xml (it this case activeio-core but same situation for all dependencies in pom.xml)

        Show
        Martin Kočí added a comment - Patch from Memory Analyzer. You can see 5 instances of org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent$ResourceAdapter hold with org.eclipse.wst.common.internal.emf.resource.ReferencedXMIResourceImpl$ESynchronizedAdapterList Whats important all 5 instances refers same dependency from pom.xml (it this case activeio-core but same situation for all dependencies in pom.xml)
        Hide
        Fred Bricon added a comment -

        Thanks for your analysis Martin.
        org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent belongs to WTP - Common component, can you please open a ticket at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=WTP%20Common%20Tools

        We'll see what the WTP folks say : either they fix it on their side or give instructions to properly address this issue.

        Show
        Fred Bricon added a comment - Thanks for your analysis Martin. org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent belongs to WTP - Common component, can you please open a ticket at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=WTP%20Common%20Tools We'll see what the WTP folks say : either they fix it on their side or give instructions to properly address this issue.
        Hide
        Fred Bricon added a comment -

        Also could you please attach a sample test project? Thx

        Show
        Fred Bricon added a comment - Also could you please attach a sample test project? Thx
        Hide
        Martin Kočí added a comment -

        Sample project attached.

        Show
        Martin Kočí added a comment - Sample project attached.
        Hide
        Martin Kočí added a comment -
        ReferencedXMIResourceImpl$ESynchronizedAdapterList.add(Object) line: 58	
        J2EEModuleVirtualComponent(VirtualComponent).addManagedResource() line: 102	
        J2EEModuleVirtualComponent(VirtualComponent).initializeResource() line: 114	
        J2EEModuleVirtualComponent(VirtualComponent).<init>(IProject, IPath) line: 148	
        J2EEModuleVirtualComponent.<init>(IProject, IPath) line: 92	
        J2EEModuleVirtualComponent.createComponent(IProject) line: 96	
        ComponentImplManager.createComponent(IProject, boolean) line: 215	
        ComponentCore.createComponent(IProject, boolean) line: 84	
        WebProjectConfiguratorDelegate.configure(IProject, MavenProject, IProgressMonitor) line: 105	
        WebProjectConfiguratorDelegate(AbstractProjectConfiguratorDelegate).configureProject(IProject, MavenProject, IProgressMonitor) line: 87	
        WTPProjectConfigurator.configure(ProjectConfigurationRequest, IProgressMonitor) line: 54	
        WarLifecycleMapping(AbstractLifecycleMapping).configure(ProjectConfigurationRequest, IProgressMonitor) line: 109	
        ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationRequest, IProgressMonitor) line: 414	
        ProjectConfigurationManager.updateProjectConfiguration(MavenUpdateRequest, boolean, boolean, IProgressMonitor) line: 351	
        UpdateMavenProjectJob.runInWorkspace(IProgressMonitor) line: 74	
        UpdateMavenProjectJob(InternalWorkspaceJob).run(IProgressMonitor) line: 38	
        Worker.run() line: 54	
        

        This invocation adds a new VirtualComponent and this VirtualComponent represents Project itself.
        But I see 2 two problems in wtp code
        1) ESynchronizedAdapterList uses identity equals, ie contains() method uses == during lookup
        2) even with equals() in contains(), ResourceAdapter has this implementaion of equals: return this.getClass().equals(arg0.getClass()) (equals() based only on class identity looks very odd!)

        suggestions: m2e-wtp invokes ComponentCore.createComponent - prefix "create" indicates new instances. Is there API like ComponentCore.getComponent() that returns already existing VirtualComponent ? This is really a wild guess, have no knowledge of eclipse APIs.

        bug for WTP project: based on previous call stack, is there a way how to simulate this problem without m2e and m2e-wtp, just with plain eclipse and WTP? I didn't find it yet.

        Show
        Martin Kočí added a comment - ReferencedXMIResourceImpl$ESynchronizedAdapterList.add( Object ) line: 58 J2EEModuleVirtualComponent(VirtualComponent).addManagedResource() line: 102 J2EEModuleVirtualComponent(VirtualComponent).initializeResource() line: 114 J2EEModuleVirtualComponent(VirtualComponent).<init>(IProject, IPath) line: 148 J2EEModuleVirtualComponent.<init>(IProject, IPath) line: 92 J2EEModuleVirtualComponent.createComponent(IProject) line: 96 ComponentImplManager.createComponent(IProject, boolean ) line: 215 ComponentCore.createComponent(IProject, boolean ) line: 84 WebProjectConfiguratorDelegate.configure(IProject, MavenProject, IProgressMonitor) line: 105 WebProjectConfiguratorDelegate(AbstractProjectConfiguratorDelegate).configureProject(IProject, MavenProject, IProgressMonitor) line: 87 WTPProjectConfigurator.configure(ProjectConfigurationRequest, IProgressMonitor) line: 54 WarLifecycleMapping(AbstractLifecycleMapping).configure(ProjectConfigurationRequest, IProgressMonitor) line: 109 ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationRequest, IProgressMonitor) line: 414 ProjectConfigurationManager.updateProjectConfiguration(MavenUpdateRequest, boolean , boolean , IProgressMonitor) line: 351 UpdateMavenProjectJob.runInWorkspace(IProgressMonitor) line: 74 UpdateMavenProjectJob(InternalWorkspaceJob).run(IProgressMonitor) line: 38 Worker.run() line: 54 This invocation adds a new VirtualComponent and this VirtualComponent represents Project itself. But I see 2 two problems in wtp code 1) ESynchronizedAdapterList uses identity equals, ie contains() method uses == during lookup 2) even with equals() in contains(), ResourceAdapter has this implementaion of equals: return this.getClass().equals(arg0.getClass()) (equals() based only on class identity looks very odd!) suggestions: m2e-wtp invokes ComponentCore.createComponent - prefix "create" indicates new instances. Is there API like ComponentCore.getComponent() that returns already existing VirtualComponent ? This is really a wild guess, have no knowledge of eclipse APIs. bug for WTP project: based on previous call stack, is there a way how to simulate this problem without m2e and m2e-wtp, just with plain eclipse and WTP? I didn't find it yet.
        Hide
        Fred Bricon added a comment -

        I created https://bugs.eclipse.org/bugs/show_bug.cgi?id=377998 to follow up on the WTP side

        Show
        Fred Bricon added a comment - I created https://bugs.eclipse.org/bugs/show_bug.cgi?id=377998 to follow up on the WTP side
        Hide
        Martin Kočí added a comment -

        How to whip up WTP team to get a answer ?

        There is a workaround for now: close view "Servers" and use "Run configuration" instead. Instances do not grow up then.

        Show
        Martin Kočí added a comment - How to whip up WTP team to get a answer ? There is a workaround for now: close view "Servers" and use "Run configuration" instead. Instances do not grow up then.
        Hide
        Fred Bricon added a comment -

        Your best chance is to provide a patch on BZ. I have no more power than you to speed things up.

        Show
        Fred Bricon added a comment - Your best chance is to provide a patch on BZ. I have no more power than you to speed things up.

          People

          • Assignee:
            Fred Bricon
            Reporter:
            Martin Kočí
            Last Updated By:
            Fred Bricon
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Date of First Response: