> 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.
> 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.
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.