Spring Framework
  1. Spring Framework
  2. SPR-9628

high memory consumption on 64-bit JVMs when managing swing-components

    Details

    • Last commented by a User:
      true

      Description

      Hi,

      i have been using spring for managing a swing-based client-application recently for the first time, and noticed some strange behaviour: On 64-Bit JVMs the application seems to eat up a lot more memory than expected (about 10 times the memory it uses on 32-Bit JVMs).

      My application, which consists out of only 11 swing-components that are wired together with spring easily eats up 400MB memory. Even the most basic application (one JFrame and one JPanel that gets injected into that Frame) use up more than 150MB already. I will attach a simple test-project (just that 2 classes + applicationContext.xml + required libraries), so you can see for yourself.

      In a memory dump you can see that a lot of java.lang.reflect.Method objects are created, maybe because JFrame (and other Swing Components) inherits like 100 methods or so? See the following answer on stackoverflow: http://stackoverflow.com/a/11620952/1164797 (forget/ignore the question itself though, initially i thought this is related to AnnotationConfigApplicationContext, which i now know is not the case).

      I am not sure, maybe this is just expected because of the number of methods JFrame has? So this might not be a bug at all.. Still, 150MBs for 2 beans seems just unreasonable, doesn't it?

        Activity

        Hide
        mat rium added a comment -

        Forgot to mention that the performance is bad too, the initialization/refresh of the applicationcontext takes much longer than it does on 32-bit. Also this problem seems easily reproduceable on any machine/operating system we tested so far (win7, win server 2008, ubuntu, mac ox), as long as 64-bit JVM is used. With 32-Bit JVM everything seems all right, startup is really fast and the memory consumption is lower by a factor 5 to 10.

        Show
        mat rium added a comment - Forgot to mention that the performance is bad too, the initialization/refresh of the applicationcontext takes much longer than it does on 32-bit. Also this problem seems easily reproduceable on any machine/operating system we tested so far (win7, win server 2008, ubuntu, mac ox), as long as 64-bit JVM is used. With 32-Bit JVM everything seems all right, startup is really fast and the memory consumption is lower by a factor 5 to 10.
        Hide
        Pavel Kotlov added a comment -

        Using Spring along with Swing seems not a good idea at all. If we cannot resolve the issue it would be great to know how someone can avoid this behavior.
        ->Removing Components extending JPanels or JFrames?

        Show
        Pavel Kotlov added a comment - Using Spring along with Swing seems not a good idea at all. If we cannot resolve the issue it would be great to know how someone can avoid this behavior. ->Removing Components extending JPanels or JFrames?

          People

          • Assignee:
            Unassigned
            Reporter:
            mat rium
            Last updater:
            Chris Beams
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              1 year, 33 weeks, 2 days ago