jtabbedpane memory leak

I'm using java 1.5.9SE and netbeans5.5. My experience is, when I make a jtabbedpane with some page (with panel, and other components), and I dispose the jframe (with jtabbedpane), the garbage collector not deleted from heap the jtabbedpane and it's childs. This is a Java se bug?
[288 byte] By [flexgta] at [2007-10-3 9:48:27]
# 1

> I'm using java 1.5.9SE and netbeans5.5. My experience

> is, when I make a jtabbedpane with some page (with

> panel, and other components), and I dispose the

> jframe (with jtabbedpane), the garbage collector not

> deleted from heap the jtabbedpane and it's childs.

How do you know that is it never deleted from the heap. Do you have a reference to it?

> This is a Java se bug?

Very Doubtful.

zadoka at 2007-7-15 5:05:37 > top of Java-index,Desktop,Core GUI APIs...
# 2
I exam with jprofile. If I set the components to null in close event, then reference dissappear, but this solution not good with 50-100 components :( This problem exist just with jtabbedpane.
flexgta at 2007-7-15 5:05:37 > top of Java-index,Desktop,Core GUI APIs...
# 3
> but this> solution not good with 50-100 components :( This> problem exist just with jtabbedpane.What problem?What do you mean not good with 50-100 components. What is wrong with setting something to null that you are not using?
zadoka at 2007-7-15 5:05:37 > top of Java-index,Desktop,Core GUI APIs...
# 4
If I don't use jtappedpane, the java delete the components automatic. I don't find solution, how I set null many components in loop. getcomponent(i) = null throw error: object not referenced, so I have to write each components with name: label1 = null; and so on. I should don't like
flexgta at 2007-7-15 5:05:37 > top of Java-index,Desktop,Core GUI APIs...
# 5

> If I don't use jtappedpane, the java delete the

> components automatic.

Java doesn't delete anything automatically your code determines what happens.

>I don't find solution, how I

> set null many components in loop. getcomponent(i) =

> null throw error: object not referenced, so I have to

> write each components with name: label1 = null; and

> so on. I should don't like this.

I don't like it either. You shouldn't have to do that.Your code is bad (no offense). If you are done with a component just make sure you don't have references to it and it will be taken by the GC.

zadoka at 2007-7-15 5:05:37 > top of Java-index,Desktop,Core GUI APIs...
# 6

Curiousity question:

Isn't dispose() supposed to do this, i.e. remove references to the JFrame and its child components?

>>

public void dispose()

Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.

The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifications between those actions).

<<

When he calls dispose on his JFrame, shouldn't that remove all the resources the JFrame is using, including those taken up by the JTabbedPane and its child components (buttons, labels, etc)? Does dispose() mark all these components for GC, or is there something else going on here?

Just trying to find out exactly what dispose() is doing, especially with respect to this situation.

cimmerian76a at 2007-7-15 5:05:37 > top of Java-index,Desktop,Core GUI APIs...
# 7
folks, this is a known bug starting with jdk1.5.0_08. search the forums or sun's bug database.
dberanskya at 2007-7-15 5:05:37 > top of Java-index,Desktop,Core GUI APIs...