cleanConnectorMap unregistered connector

Moved to Framework forum

[s]
Some time ago I ask about this error but didnt get any answer, can someone please help me with this? , I need to know why this happen, and know how to fix it.

I have an inbox of n number of task, I have created a component to show the task, but every time I reload the inbox or change the view I got lots of errors refering to every element contained on this component. Every Label, Button, Image, get a ’ cleanConnectorMap unregistered connector’ error and that multiplies for the n tasks on the inbox, this is messing up the performance of the application. Can some one help me with this problem, I have tryed to recreate the component using the elements on other way but still got the problem.

Thanks in advance.
[/s]

Well I find out what was the problem, I was removing the component from the inbox view, but the parts of that component still where somewhere on the memory. I create Array repository, and remove them one by one.

instead of:

vlInboxContainer.removeAllComponents();

I did something like:

for(Task task : inboxTas){
  vlInboxContainer.removeComponent(tasl);
   task = null;
}

I dont know if is correct but fot now works, I plan to redo this view later.

I’m having a similar issue and for other people searching this:

The 2 pieces of code do exactly the same thing.

In “removeAllComponents” the removeComponent(child) is called for the entire component list.
and setting task = null at the end of a loop does nothing either. Since task is only valid in the loop scope.

well the removeAllComponents will remove every child component attach to that layout, the removeComponent(child) will remove only that child, Maybe one of the childs is still there. try with the getComponentCount() to check if is empty.

The task = null is to destroy the component and prevent the ‘cleanConnectorMap unregistered connector’ error.

Ok, if the inbox list in that loop does not contain all the components there is a difference. However. Setting a reference to null does not destroy the component, it only clears the loops local reference which would be cleared anyway at the end of the loop. The list still has the reference.

Mhhh not sure about that , this has worked for me, the error stop and the performance of my application was fixed, I just did something similar for other part of my app, using the getComponentCount():

int i = cardContainer.getComponentCount();
ArrayList<Component> cmps = new ArrayList<>();
for(int j=0 ; j<i ; j++){
if( cardContainer.getComponent(j) != null) {
   cmps.add(cardContainer.getComponent(j));
} }
for(Component cmp : cmps){
  cardContainer.removeComponent(cmp); cmp=null;
}

You might want to look into Java references and variable scopes. Concider this:

A foreach loop is basically a for loop with a slightly different notation:

for(Object o : list) { o.doAThing(); } is the same as:

for(int i=0;i<list.size();i++)
{
  Object o = list.get(i);
  o.doAThing();
}
[/code]in both cases the Object o is a loop local variable which goes out of scope at the end of an iteration. Which means the reference is gone. Pointing the reference to null at the end of a loop also releases the reference but since it would be gone at the end anyway it does nothing extra.


About the removeAllComponents. This is the code in vaadin 7.7.6:

[code]
@Override
public void removeAllComponents() {
    final LinkedList<Component> l = new LinkedList<>();

    // Adds all components
    for (final Iterator<Component> i = getComponentIterator(); i
            .hasNext();) {
        l.add(i.next());
    }

    // Removes all component
    for (Component aL : l) {
        removeComponent(aL);
    }
}
[/code]
It basically builds a componentList and calls removeComponent() on all of the entries. So in essence exactly the same as your code.


Want to test it? Try this:[code]
public class MyLabel extends Label
{
    public MyLabel()
    {
        System.out.println("Creating myLabel: " + hashCode());
    }

    @Override
    protected void finalize() throws Throwable
    {
        System.out.println("Releasing myLabel from memory: " + hashCode());
        super.finalize();
    }
}

and

public class TestUI extends UI { @Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); for(int i=0;i<5;i++) { layout.addComponent(new MyLabel()); } layout.removeAllComponents(); System.gc(); } } your output should show something like:

Creating myLabel: 865221005
Creating myLabel: 515573790
Creating myLabel: 452912810
Creating myLabel: 1579523080
Creating myLabel: 1476612544
Releasing myLabel from memory: 865221005
Releasing myLabel from memory: 1476612544
Releasing myLabel from memory: 1579523080
Releasing myLabel from memory: 452912810
Releasing myLabel from memory: 515573790

In the end I found my problem was in overriding detach without calling super.detach(); which made my view not clean up its children.